backbone-bucket 0.4.5

Bucket Bounded Context: File Storage Module for Backbone Framework
Documentation
//! CQRS Queries
//!
//! Generated by backbone-schema. Do not edit manually.
//!
//! Queries represent requests for data without side effects.

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

// ============================================================================
// GENERIC QUERY HANDLER TRAIT
// ============================================================================

/// Generic query handler trait for CQRS pattern
///
/// Implements the handler pattern for CQRS queries.
/// Each query type should have a corresponding handler implementation.
///
/// # Example
/// ```ignore
/// #[async_trait]
/// impl QueryHandler<GetUserByIdQuery> for GetUserByIdHandler {
///     type Output = Option<User>;
///
///     async fn handle(&self, query: GetUserByIdQuery) -> Result<Self::Output> {
///         // Handle query execution
///     }
/// }
/// ```
#[async_trait]
pub trait QueryHandler<Q: Send>: Send + Sync {
    /// The output type produced by handling the query
    type Output: Send;

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

/// Query bus for routing queries to their handlers
///
/// Provides a central dispatch mechanism for queries,
/// enabling loose coupling between query producers and handlers.
pub struct QueryBus;

impl QueryBus {
    /// Create a new query bus
    pub fn new() -> Self {
        Self
    }

    /// Dispatch a query to its handler
    pub async fn dispatch<Q, H>(&self, handler: &H, query: Q) -> Result<H::Output>
    where
        Q: Send,
        H: QueryHandler<Q>,
    {
        handler.handle(query).await
    }
}

impl Default for QueryBus {
    fn default() -> Self {
        Self::new()
    }
}

mod access_log_queries;
mod bucket_queries;
mod content_hash_queries;
mod conversion_job_queries;
mod file_comment_queries;
mod file_lock_queries;
mod file_share_queries;
mod file_version_queries;
mod processing_job_queries;
mod stored_file_queries;
mod thumbnail_queries;
mod upload_session_queries;
mod user_quota_queries;

// Re-exports
pub use access_log_queries::*;
pub use bucket_queries::*;
pub use content_hash_queries::*;
pub use conversion_job_queries::*;
pub use file_comment_queries::*;
pub use file_lock_queries::*;
pub use file_share_queries::*;
pub use file_version_queries::*;
pub use processing_job_queries::*;
pub use stored_file_queries::*;
pub use thumbnail_queries::*;
pub use upload_session_queries::*;
pub use user_quota_queries::*;