validator: implement create operations

This commit is contained in:
2025-04-02 14:45:11 -07:00
committed by Quaternions
parent 8776936e96
commit 3699ce5cbb
8 changed files with 306 additions and 45 deletions

@ -0,0 +1,42 @@
use crate::nats_types::CreateSubmissionRequest;
use crate::create::CreateRequest;
#[allow(dead_code)]
#[derive(Debug)]
pub enum Error{
ApiActionSubmissionCreate(submissions_api::Error),
}
impl std::fmt::Display for Error{
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
write!(f,"{self:?}")
}
}
impl std::error::Error for Error{}
impl crate::message_handler::MessageHandler{
pub async fn create_submission(&self,create_info:CreateSubmissionRequest)->Result<(),Error>{
let create_result=self.create_inner(CreateRequest{
ModelID:create_info.ModelID,
}).await;
match create_result{
Ok(create_request)=>{
// call create on api
self.api.create_submission(submissions_api::types::CreateSubmissionRequest{
OperationID:create_info.OperationID,
AssetOwner:create_request.AssetOwner,
DisplayName:create_request.DisplayName.as_str(),
Creator:create_request.Creator.as_str(),
GameID:create_request.GameID,
AssetID:create_info.ModelID,
AssetVersion:create_request.AssetVersion,
}).await.map_err(Error::ApiActionSubmissionCreate)?;
},
Err(e)=>{
println!("oh no! {e}");
},
}
Ok(())
}
}