XmtpMlsStorageProvider

Trait XmtpMlsStorageProvider 

Source
pub trait XmtpMlsStorageProvider:
    MaybeSend
    + MaybeSync
    + StorageProvider<CURRENT_VERSION, Error = SqlKeyStoreError> {
    type Connection: ConnectionExt;
    type TxQuery: TransactionalKeyStore;
    type DbQuery<'a>: DbQuery
       where Self::Connection: 'a;

    // Required methods
    fn db<'a>(&'a self) -> Self::DbQuery<'a>;
    fn transaction<T, E, F>(&self, f: F) -> Result<T, E>
       where F: FnOnce(&mut Self::TxQuery) -> Result<T, E>,
             E: From<Error> + From<ConnectionError> + Error;
    fn savepoint<T, E, F>(&self, f: F) -> Result<T, E>
       where F: FnOnce(&mut Self::TxQuery) -> Result<T, E>,
             E: From<Error> + From<ConnectionError> + Error;
    fn read<V: Entity<CURRENT_VERSION>>(
        &self,
        label: &[u8],
        key: &[u8],
    ) -> Result<Option<V>, SqlKeyStoreError>;
    fn read_list<V: Entity<CURRENT_VERSION>>(
        &self,
        label: &[u8],
        key: &[u8],
    ) -> Result<Vec<V>, <Self as StorageProvider<CURRENT_VERSION>>::Error>;
    fn delete(
        &self,
        label: &[u8],
        key: &[u8],
    ) -> Result<(), <Self as StorageProvider<CURRENT_VERSION>>::Error>;
    fn write(
        &self,
        label: &[u8],
        key: &[u8],
        value: &[u8],
    ) -> Result<(), <Self as StorageProvider<CURRENT_VERSION>>::Error>;
    fn hash_all(&self) -> Result<Vec<u8>, SqlKeyStoreError>;

    // Provided method
    fn _disable_lint_for_self<'a>(_: Self::DbQuery<'a>) { ... }
}
Expand description

Convenience super trait to constrain the storage provider to a specific error type and version This storage provider is likewise implemented on both &T and T references, to allow creating a referenced or owned provider.

Required Associated Types§

Source

type Connection: ConnectionExt

An Opaque Database connection type. Can be anything.

Source

type TxQuery: TransactionalKeyStore

Source

type DbQuery<'a>: DbQuery where Self::Connection: 'a

Required Methods§

Source

fn db<'a>(&'a self) -> Self::DbQuery<'a>

Source

fn transaction<T, E, F>(&self, f: F) -> Result<T, E>
where F: FnOnce(&mut Self::TxQuery) -> Result<T, E>, E: From<Error> + From<ConnectionError> + Error,

Start a new transaction

Source

fn savepoint<T, E, F>(&self, f: F) -> Result<T, E>
where F: FnOnce(&mut Self::TxQuery) -> Result<T, E>, E: From<Error> + From<ConnectionError> + Error,

Start a savepoint within a transaction Must only be used when already in a transaction

Source

fn read<V: Entity<CURRENT_VERSION>>( &self, label: &[u8], key: &[u8], ) -> Result<Option<V>, SqlKeyStoreError>

Source

fn read_list<V: Entity<CURRENT_VERSION>>( &self, label: &[u8], key: &[u8], ) -> Result<Vec<V>, <Self as StorageProvider<CURRENT_VERSION>>::Error>

Source

fn delete( &self, label: &[u8], key: &[u8], ) -> Result<(), <Self as StorageProvider<CURRENT_VERSION>>::Error>

Source

fn write( &self, label: &[u8], key: &[u8], value: &[u8], ) -> Result<(), <Self as StorageProvider<CURRENT_VERSION>>::Error>

Source

fn hash_all(&self) -> Result<Vec<u8>, SqlKeyStoreError>

Provided Methods§

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§