pub trait UnifiedEntity: PrimaryKey + Sized {
const COLLECTION_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 COLLECTION_NAME: &'static str
const COLLECTION_NAME: &'static str
The table name 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) -> CoreCryptoKeystoreResult<Option<Self>> {
Self::get_borrowed(conn, key).await
}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", so this trait is not object safe.