pub enum EntityStatus {
New,
Persisted,
PersistedDeleted,
Updated,
UpdatedDeleted,
UpdatedRecover,
Refer,
}Expand description
Tracks the lifecycle status of an entity through a state machine.
State transitions follow the Java TeaQL transition table exactly:
| Current State | Action | Next State |
|---|---|---|
| New | Update | New |
| New | Persist | Persisted |
| Persisted | Update | Updated |
| Persisted | Delete | UpdatedDeleted |
| PersistedDeleted | Recover | UpdatedRecover |
| Updated | Update | Updated |
| Updated | Persist | Persisted |
| UpdatedDeleted | Persist | PersistedDeleted |
| UpdatedDeleted | Delete | UpdatedDeleted |
| UpdatedRecover | Persist | Persisted |
| UpdatedRecover | Recover | UpdatedRecover |
Variants§
New
A newly created entity that has not been persisted yet.
Persisted
An entity that has been persisted to the database.
PersistedDeleted
A persisted entity that has been soft-deleted.
Updated
A persisted entity with pending updates.
UpdatedDeleted
A persisted entity that has been updated and then deleted.
UpdatedRecover
A deleted entity that has been recovered (undeleted).
Refer
A reference to an entity managed elsewhere.
Implementations§
Source§impl EntityStatus
impl EntityStatus
Sourcepub fn next(self, action: EntityAction) -> Result<EntityStatus, String>
pub fn next(self, action: EntityAction) -> Result<EntityStatus, String>
Transition to the next status given an action.
Returns Err with a descriptive message for invalid transitions.
Sourcepub fn need_persist(&self) -> bool
pub fn need_persist(&self) -> bool
Returns true if this entity needs to be persisted (i.e. it has pending changes).
Entities with status New, Updated, UpdatedDeleted, or UpdatedRecover
need persistence. Persisted, PersistedDeleted, and Refer do not.
Sourcepub fn is_new(&self) -> bool
pub fn is_new(&self) -> bool
Returns true if this entity is newly created and has never been persisted.
Sourcepub fn is_updated(&self) -> bool
pub fn is_updated(&self) -> bool
Returns true if this entity has been updated since last persistence.
Sourcepub fn is_deleted(&self) -> bool
pub fn is_deleted(&self) -> bool
Returns true if this entity is marked for deletion.
Sourcepub fn is_recover(&self) -> bool
pub fn is_recover(&self) -> bool
Returns true if this entity has been recovered from deletion.
Trait Implementations§
Source§impl Clone for EntityStatus
impl Clone for EntityStatus
Source§fn clone(&self) -> EntityStatus
fn clone(&self) -> EntityStatus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for EntityStatus
Source§impl Debug for EntityStatus
impl Debug for EntityStatus
Source§impl Default for EntityStatus
impl Default for EntityStatus
Source§impl Display for EntityStatus
impl Display for EntityStatus
impl Eq for EntityStatus
Source§impl Hash for EntityStatus
impl Hash for EntityStatus
Source§impl PartialEq for EntityStatus
impl PartialEq for EntityStatus
Source§fn eq(&self, other: &EntityStatus) -> bool
fn eq(&self, other: &EntityStatus) -> bool
self and other values to be equal, and is used by ==.