[][src]Trait cqrs_es::Aggregate

pub trait Aggregate: Default + Serialize + DeserializeOwned + Sync + Send {
    fn aggregate_type() -> &'static str;
}

In CQRS (and Domain Driven Design) an Aggregate is the fundamental component that encapsulates the state and application logic (aka business rules) for the application. An Aggregate is always an entity along with all objects associated with it.

Examples

#[derive(Serialize,Deserialize)]
struct Customer {
    customer_id: String,
    name: String,
    email: String,
}

impl Aggregate for Customer {
    fn aggregate_type() -> &'static str { "customer" }
}

impl Default for Customer {fn default() -> Self {
        Customer {
            customer_id: "".to_string(),
            name: "".to_string(),
            email: "".to_string(),
        }
    }
}

Required methods

fn aggregate_type() -> &'static str

aggregate_type is a unique identifier for this aggregate

Loading content...

Implementors

Loading content...