[−][src]Trait domain_patterns::models::Entity
A trait that defines an Entity
, which is any object with a unique and globally persistent identity.
The generic type K
should match the same type as the internal globally unique id used for the entity.
Be careful when choosing what to return here. The result of id()
will be used as the primary key
for the entity when communicating with a database via a repository.
Example
use domain_patterns::models::Entity; struct User { user_id: String, email: String, password: String, } impl Entity<String> for User { fn id(&self) -> String { self.user_id.clone() } }