use async_trait::async_trait;
use anyhow::Result;
#[async_trait]
pub trait CommandHandler<C: Send>: Send + Sync {
type Output: Send;
async fn handle(&self, command: C) -> Result<Self::Output>;
}
pub struct CommandBus;
impl CommandBus {
pub fn new() -> Self {
Self
}
pub async fn dispatch<C, H>(&self, handler: &H, command: C) -> Result<H::Output>
where
C: Send,
H: CommandHandler<C>,
{
handler.handle(command).await
}
}
impl Default for CommandBus {
fn default() -> Self {
Self::new()
}
}
mod access_log_commands;
mod bucket_commands;
mod content_hash_commands;
mod conversion_job_commands;
mod file_comment_commands;
mod file_lock_commands;
mod file_share_commands;
mod file_version_commands;
mod processing_job_commands;
mod stored_file_commands;
mod thumbnail_commands;
mod upload_session_commands;
mod user_quota_commands;
pub use access_log_commands::*;
pub use bucket_commands::*;
pub use content_hash_commands::*;
pub use conversion_job_commands::*;
pub use file_comment_commands::*;
pub use file_lock_commands::*;
pub use file_share_commands::*;
pub use file_version_commands::*;
pub use processing_job_commands::*;
pub use stored_file_commands::*;
pub use thumbnail_commands::*;
pub use upload_session_commands::*;
pub use user_quota_commands::*;