atomr-patterns 0.9.2

DDD/CQRS pattern library for atomr — aggregates, readers, projections, sagas, outbox, ACL.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! [`Entity`] — anything with a stable identity.

use std::hash::Hash;

/// A domain object that is identified by its `Id`, not by its
/// attribute values. Two `Entity` instances with the same `Id` represent
/// the same conceptual thing even if their other fields differ.
pub trait Entity {
    /// The identity type. Must be hashable so the framework can index
    /// entities in maps (e.g. inside a [`crate::Repository`]).
    type Id: Clone + Eq + Hash + Send + Sync + 'static;

    /// Stable identity of this entity instance.
    fn id(&self) -> &Self::Id;
}