Entity

Trait Entity 

Source
pub trait Entity: EntityBase {
    type PrimaryKey: KeyType;

    // Required methods
    fn primary_key(&self) -> Self::PrimaryKey;
    fn get<'life0, 'life1, 'async_trait>(
        conn: &'life0 mut Self::ConnectionType,
        key: &'life1 Self::PrimaryKey,
    ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Self>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn count<'life0, 'async_trait>(
        conn: &'life0 mut Self::ConnectionType,
    ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<u32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn load_all<'life0, 'async_trait>(
        conn: &'life0 mut Self::ConnectionType,
    ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Vec<Self>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Something which can be stored in our database.

It has a primary key, which uniquely identifies it.

Required Associated Types§

Source

type PrimaryKey: KeyType

Each distinct PrimaryKey uniquely identifies either 0 or 1 instance.

This constraint should be enforced at the DB level.

Required Methods§

Source

fn primary_key(&self) -> Self::PrimaryKey

Get this entity’s primary key.

This must return an owned type, because there are some entities for which only owned primary keys are possible. However, entities which have primary keys owned within the entity itself should consider also implementing BorrowPrimaryKey for greater efficiency.

Source

fn get<'life0, 'life1, 'async_trait>( conn: &'life0 mut Self::ConnectionType, key: &'life1 Self::PrimaryKey, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Self>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

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:

async fn get(conn: &mut Self::ConnectionType, key: &Self::PrimaryKey) -> CoreCryptoKeystoreResult<Option<Self>> {
    Self::get_borrowed(conn, key).await
}
Source

fn count<'life0, 'async_trait>( conn: &'life0 mut Self::ConnectionType, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Count the number of entities of this type in the database.

Source

fn load_all<'life0, 'async_trait>( conn: &'life0 mut Self::ConnectionType, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Vec<Self>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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.

Implementors§

Source§

impl Entity for E2eiCrl

Source§

impl Entity for E2eiIntermediateCert

Source§

impl Entity for MlsPendingMessage

Pending messages have no distinct primary key; they must always be accessed via MlsPendingMessage::find_all_by_conversation_id and cleaned up with MlsPendingMessage::delete_by_conversation_id

Source§

impl Entity for PersistedMlsGroup

Source§

impl Entity for PersistedMlsPendingGroup

Source§

impl Entity for ProteusIdentity

Source§

impl Entity for ProteusPrekey

Source§

impl Entity for ProteusSession

Source§

impl Entity for StoredBufferedCommit

Source§

impl Entity for StoredCredential

Source§

impl Entity for StoredE2eiEnrollment

Source§

impl Entity for StoredEncryptionKeyPair

Source§

impl Entity for StoredEpochEncryptionKeypair

Source§

impl Entity for StoredHpkePrivateKey

Source§

impl Entity for StoredKeypackage

Source§

impl Entity for StoredPskBundle

Source§

impl<T> Entity for T