-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26c904a
commit ce95355
Showing
3 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
libs/cti/src/cves/application/create_one/create_cve_command_handler.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::sync::Arc; | ||
|
||
use async_trait::async_trait; | ||
use cqrs::domain::{command::Command, command_bus_response::CommandBusResponse, command_handler::CommandHandler}; | ||
use events::domain::event_bus::EventBus; | ||
|
||
use crate::cves::{application::cve_command_response::CveCommandResponse, domain::{entities::cve_id::CveId, repositories::cve_repository::CveRepository}}; | ||
|
||
use super::{create_cve_command::CreateCveCommand, cve_creator::CveCreator}; | ||
|
||
|
||
pub struct CreateCveCommandHandler<R: CveRepository, E: EventBus> { | ||
creator: Arc<CveCreator<R, E>>, | ||
} | ||
|
||
impl<R: CveRepository, E: EventBus> CreateCveCommandHandler<R, E> { | ||
pub fn new(creator: Arc<CveCreator<R, E>>) -> CreateCveCommandHandler<R, E> { | ||
CreateCveCommandHandler { creator } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl <R: CveRepository, E: EventBus> CommandHandler for CreateCveCommandHandler<R, E> { | ||
async fn handle(&self, command: Box<dyn Command>) -> Box<dyn CommandBusResponse> { | ||
let command = command.as_any().downcast_ref::<CreateCveCommand>().unwrap(); | ||
|
||
let id = match CveId::from_optional(&command.id) { | ||
Ok(id) => id, | ||
Err(err) => return CveCommandResponse::boxed_err(err) | ||
}; | ||
|
||
|
||
// let res = self.creator.run(id).await; | ||
|
||
/*match res { | ||
Ok(_) => CveCommandResponse::boxed_ok(), | ||
Err(err) => CryptoKeyCommandResponse::boxed_err(err) | ||
}*/ | ||
unimplemented!() | ||
} | ||
|
||
fn subscribet_to(&self) -> String { | ||
return CreateCveCommand::COMMAND_TYPE.to_string(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub mod create_cve_command; | ||
|
||
pub mod create_cve_command_handler; | ||
pub mod cve_creator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters