backbone-bucket 0.2.0

Bucket Bounded Context: File Storage Module for Backbone Framework
Documentation
//! Specifications for FileAccessLog aggregate
//!
//! Generated by backbone-schema. Do not edit manually.
//!
//! Specifications encapsulate business rules as reusable, testable objects.

use std::sync::Arc;

use super::FileAccessLog;

// ============================================================================
// SPECIFICATION TRAIT
// ============================================================================

/// Specification trait for FileAccessLog entities
///
/// Specifications encapsulate business rules that can be:
/// - Reused across the domain
/// - Combined with AND, OR, NOT operators
/// - Tested in isolation
pub trait FileAccessLogSpecification: Send + Sync {
    /// Check if the entity satisfies this specification
    fn is_satisfied_by(&self, entity: &FileAccessLog) -> bool;

    /// Combine with another specification using AND
    fn and<S: FileAccessLogSpecification + 'static>(self, other: S) -> AndFileAccessLogSpec
    where
        Self: Sized + 'static,
    {
        AndFileAccessLogSpec::new(Box::new(self), Box::new(other))
    }

    /// Combine with another specification using OR
    fn or<S: FileAccessLogSpecification + 'static>(self, other: S) -> OrFileAccessLogSpec
    where
        Self: Sized + 'static,
    {
        OrFileAccessLogSpec::new(Box::new(self), Box::new(other))
    }

    /// Negate this specification
    fn not(self) -> NotFileAccessLogSpec
    where
        Self: Sized + 'static,
    {
        NotFileAccessLogSpec::new(Box::new(self))
    }
}

// ============================================================================
// COMPOSITE SPECIFICATIONS
// ============================================================================

/// AND composite specification
pub struct AndFileAccessLogSpec {
    left: Box<dyn FileAccessLogSpecification>,
    right: Box<dyn FileAccessLogSpecification>,
}

impl AndFileAccessLogSpec {
    pub fn new(left: Box<dyn FileAccessLogSpecification>, right: Box<dyn FileAccessLogSpecification>) -> Self {
        Self { left, right }
    }
}

impl FileAccessLogSpecification for AndFileAccessLogSpec {
    fn is_satisfied_by(&self, entity: &FileAccessLog) -> bool {
        self.left.is_satisfied_by(entity) && self.right.is_satisfied_by(entity)
    }
}

/// OR composite specification
pub struct OrFileAccessLogSpec {
    left: Box<dyn FileAccessLogSpecification>,
    right: Box<dyn FileAccessLogSpecification>,
}

impl OrFileAccessLogSpec {
    pub fn new(left: Box<dyn FileAccessLogSpecification>, right: Box<dyn FileAccessLogSpecification>) -> Self {
        Self { left, right }
    }
}

impl FileAccessLogSpecification for OrFileAccessLogSpec {
    fn is_satisfied_by(&self, entity: &FileAccessLog) -> bool {
        self.left.is_satisfied_by(entity) || self.right.is_satisfied_by(entity)
    }
}

/// NOT composite specification
pub struct NotFileAccessLogSpec {
    spec: Box<dyn FileAccessLogSpecification>,
}

impl NotFileAccessLogSpec {
    pub fn new(spec: Box<dyn FileAccessLogSpecification>) -> Self {
        Self { spec }
    }
}

impl FileAccessLogSpecification for NotFileAccessLogSpec {
    fn is_satisfied_by(&self, entity: &FileAccessLog) -> bool {
        !self.spec.is_satisfied_by(entity)
    }
}

// ============================================================================
// GENERATED SPECIFICATIONS
// ============================================================================

// ============================================================================
// CUSTOM SPECIFICATIONS
// ============================================================================

// <<< CUSTOM SPECIFICATIONS START >>>
// Add your custom specifications here
// Example:
// 
// pub struct FileAccessLogHasValidEmailSpec;
// 
// impl FileAccessLogSpecification for FileAccessLogHasValidEmailSpec {
//     fn is_satisfied_by(&self, entity: &FileAccessLog) -> bool {
//         entity.email.contains('@')
//     }
// }
// <<< CUSTOM SPECIFICATIONS END >>>