FetchFromDatabase

Trait FetchFromDatabase 

Source
pub trait FetchFromDatabase: Send + Sync {
    // Required methods
    fn get<'life0, 'life1, 'async_trait, E>(
        &'life0 self,
        id: &'life1 <E as Entity>::PrimaryKey,
    ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<E>>> + Send + 'async_trait>>
       where E: Entity<ConnectionType = KeystoreDatabaseConnection> + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn count<'life0, 'async_trait, E>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<u32>> + Send + 'async_trait>>
       where E: Entity<ConnectionType = KeystoreDatabaseConnection> + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn load_all<'life0, 'async_trait, E>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Vec<E>>> + Send + 'async_trait>>
       where E: Entity<ConnectionType = KeystoreDatabaseConnection> + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn get_unique<'life0, 'async_trait, U>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<U>>> + Send + 'async_trait>>
       where U: UniqueEntity<ConnectionType = KeystoreDatabaseConnection> + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Interface to fetch from the database either from the connection directly or through a transaction.

Fundamentally these are convenience methods, allowing you to do let n_foos = database.count::<Foo>() instead of Foo::count(&mut database.conn).

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait, E>( &'life0 self, id: &'life1 <E as Entity>::PrimaryKey, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<E>>> + Send + 'async_trait>>
where E: Entity<ConnectionType = KeystoreDatabaseConnection> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an instance of E from the database by its primary key.

Source

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

Count the number of Es in the database.

Source

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

Load all Es from the database.

Source

fn get_unique<'life0, 'async_trait, U>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<U>>> + Send + 'async_trait>>
where U: UniqueEntity<ConnectionType = KeystoreDatabaseConnection> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get the requested unique entity 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§