pub trait Entity: PrimaryKey + Sized {
const TABLE_NAME: &'static str;
// Required methods
fn get(
conn: &Connection,
key: &Self::PrimaryKey,
) -> CryptoKeystoreResult<Option<Self>>;
fn count(conn: &Connection) -> CryptoKeystoreResult<u32>;
fn load_all(conn: &Connection) -> CryptoKeystoreResult<Vec<Self>>;
}Expand description
Something which can be stored in our database.
It has a primary key, which uniquely identifies it.
Required Associated Constants§
Sourceconst TABLE_NAME: &'static str
const TABLE_NAME: &'static str
The name of the SQL table for this entity
Required Methods§
Sourcefn get(
conn: &Connection,
key: &Self::PrimaryKey,
) -> CryptoKeystoreResult<Option<Self>>
fn get( conn: &Connection, key: &Self::PrimaryKey, ) -> CryptoKeystoreResult<Option<Self>>
Get an entity by its primary key.
For entites whose primary key has a distinct borrowed type, it is best to implement this as a direct passthrough:
ⓘ
fn get(conn: &Connection, key: &Self::PrimaryKey) -> CryptoKeystoreResult<Option<Self>> {
<Self as EntityGetBorrowed>::get_borrowed(conn, key)
}Sourcefn count(conn: &Connection) -> CryptoKeystoreResult<u32>
fn count(conn: &Connection) -> CryptoKeystoreResult<u32>
Count the number of entities of this type in the database.
Sourcefn load_all(conn: &Connection) -> CryptoKeystoreResult<Vec<Self>>
fn load_all(conn: &Connection) -> CryptoKeystoreResult<Vec<Self>>
Retrieve all entities of this type from the database.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".