backbone-bucket 0.3.0

Bucket Bounded Context: File Storage Module for Backbone Framework
Documentation
//! CQRS Commands
//!
//! Generated by backbone-schema. Do not edit manually.
//!
//! Commands represent intent to change state.

use async_trait::async_trait;
use anyhow::Result;

// ============================================================================
// GENERIC COMMAND HANDLER TRAIT
// ============================================================================

/// Generic command handler trait for CQRS pattern
///
/// Implements the handler pattern for CQRS commands.
/// Each command type should have a corresponding handler implementation.
///
/// # Example
/// ```ignore
/// #[async_trait]
/// impl CommandHandler<CreateUserCommand> for CreateUserHandler {
///     type Output = User;
///
///     async fn handle(&self, cmd: CreateUserCommand) -> Result<Self::Output> {
///         // Handle user creation
///     }
/// }
/// ```
#[async_trait]
pub trait CommandHandler<C: Send>: Send + Sync {
    /// The output type produced by handling the command
    type Output: Send;

    /// Handle the command and produce a result
    async fn handle(&self, command: C) -> Result<Self::Output>;
}

/// Command bus for routing commands to their handlers
///
/// Provides a central dispatch mechanism for commands,
/// enabling loose coupling between command producers and handlers.
pub struct CommandBus;

impl CommandBus {
    /// Create a new command bus
    pub fn new() -> Self {
        Self
    }

    /// Dispatch a command to its handler
    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;

// Re-exports
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::*;