pub trait Entity: TeaqlEntity + Sized {
// Required methods
fn from_record(record: Record) -> Result<Self, EntityError>;
fn into_record(self) -> Record;
// Provided methods
fn dirty_fields(&self) -> Option<BTreeSet<String>> { ... }
fn is_marked_as_delete(&self) -> bool { ... }
fn is_new(&self) -> bool { ... }
fn mark_as_new(&mut self) { ... }
fn get_comment(&self) -> Option<String> { ... }
fn set_comment(&mut self, _comment: String) { ... }
fn audit_as(self, comment: impl Into<String>) -> Audited<Self> { ... }
fn original_values(&self) -> Option<BTreeMap<String, Value>> { ... }
fn on_loaded(&mut self, context: &dyn Any) { ... }
fn into_json(self) -> Value { ... }
}Required Methods§
fn from_record(record: Record) -> Result<Self, EntityError>
fn into_record(self) -> Record
Provided Methods§
Sourcefn dirty_fields(&self) -> Option<BTreeSet<String>>
fn dirty_fields(&self) -> Option<BTreeSet<String>>
Returns the set of field names that have been modified since the entity was loaded.
Returns None if dirty tracking is not available (backwards compatible default).
This is the Rust equivalent of Java’s entity.getUpdatedProperties().
Sourcefn is_marked_as_delete(&self) -> bool
fn is_marked_as_delete(&self) -> bool
Returns true if this entity has been marked for deletion.
Sourcefn is_new(&self) -> bool
fn is_new(&self) -> bool
Returns true if this entity was explicitly constructed as a new entity.
Sourcefn mark_as_new(&mut self)
fn mark_as_new(&mut self)
Mark this entity as a newly created entity, bypassing database existence checks.
Sourcefn get_comment(&self) -> Option<String>
fn get_comment(&self) -> Option<String>
Get the annotation comment, if any.
Sourcefn set_comment(&mut self, _comment: String)
fn set_comment(&mut self, _comment: String)
Set an annotation comment for this entity instance.
Sourcefn audit_as(self, comment: impl Into<String>) -> Audited<Self>
fn audit_as(self, comment: impl Into<String>) -> Audited<Self>
Attach an audit comment and return a Commented<Self> wrapper.
This is the only way to unlock the .save() method.
Sourcefn original_values(&self) -> Option<BTreeMap<String, Value>>
fn original_values(&self) -> Option<BTreeMap<String, Value>>
Get the original snapshot values when this entity was loaded from the repository, if available.
Sourcefn on_loaded(&mut self, context: &dyn Any)
fn on_loaded(&mut self, context: &dyn Any)
Invoked immediately after the entity is loaded from the repository. Used by implementations to attach runtime contexts or initialize internal states.
fn into_json(self) -> Value
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".