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§
Sourcefn table_name() -> &'static str
fn table_name() -> &'static str
The name of the db table where the implementing struct is mapped to.
Sourcefn id(&self) -> Option<Uuid>
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
Sourcefn version(&self) -> Option<i32>
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
fn set_id(&mut self, uuid: Uuid)
fn set_version(&mut self, version: i32)
Provided Methods§
Sourcefn table_name1(&self) -> &'static str
fn table_name1(&self) -> &'static str
Table name from instance
Sourcefn select_part() -> String
fn select_part() -> String
Convenience function that returns the select part for the associated db table.
Sourcefn select_part1(&self) -> String
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.