Skip to main content

Entity

Trait Entity 

Source
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§

Provided Methods§

Source

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().

Source

fn is_marked_as_delete(&self) -> bool

Returns true if this entity has been marked for deletion.

Source

fn is_new(&self) -> bool

Returns true if this entity was explicitly constructed as a new entity.

Source

fn mark_as_new(&mut self)

Mark this entity as a newly created entity, bypassing database existence checks.

Source

fn get_comment(&self) -> Option<String>

Get the annotation comment, if any.

Source

fn set_comment(&mut self, _comment: String)

Set an annotation comment for this entity instance.

Source

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.

Source

fn original_values(&self) -> Option<BTreeMap<String, Value>>

Get the original snapshot values when this entity was loaded from the repository, if available.

Source

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.

Source

fn into_json(self) -> Value

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§