Skip to main content

DbData

Trait DbData 

Source
pub trait DbData: Serialize + DeserializeOwned {
    // Required methods
    fn table_name() -> &'static str;
    fn id(&self) -> Option<Uuid>;
    fn version(&self) -> Option<i32>;
    fn set_id(&mut self, uuid: Uuid);
    fn set_version(&mut self, version: i32);

    // Provided methods
    fn table_name1(&self) -> &'static str { ... }
    fn select_part() -> String { ... }
    fn select_part1(&self) -> String { ... }
}
Expand description

This trait is maps data in a data table and it’s used along with DbEntity structure

Required Methods§

Source

fn table_name() -> &'static str

The name of the db table where the implementing struct is mapped to.

Source

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

returns the “id” column of the db row (same as DbEntity::id). If the DbData is not connected to the db, then result is None

Source

fn version(&self) -> Option<i32>

returns the “version” column of the db row (same as DbEntity::version). If the DbData is not connected to the db, then result is None

Source

fn set_id(&mut self, uuid: Uuid)

Source

fn set_version(&mut self, version: i32)

Provided Methods§

Source

fn table_name1(&self) -> &'static str

Table name from instance

Source

fn select_part() -> String

Convenience function that returns the select part for the associated db table.

Source

fn select_part1(&self) -> String

Select part from instance

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§