Skip to main content

Entity

Trait Entity 

Source
pub trait Entity {
    // Required methods
    fn id(&self) -> Option<&str>;
    fn table_name() -> &'static str
       where Self: Sized;

    // Provided methods
    fn is_deleted(&self) -> bool { ... }
    fn created_at(&self) -> Option<NaiveDateTime> { ... }
    fn updated_at(&self) -> Option<NaiveDateTime> { ... }
}
Expand description

Generic entity trait that all repository entities must implement

Required Methods§

Source

fn id(&self) -> Option<&str>

Get the entity’s ID

Source

fn table_name() -> &'static str
where Self: Sized,

Get the table name for this entity

Provided Methods§

Source

fn is_deleted(&self) -> bool

Check if entity is soft deleted

Source

fn created_at(&self) -> Option<NaiveDateTime>

Get creation timestamp

Source

fn updated_at(&self) -> Option<NaiveDateTime>

Get update timestamp

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§