Trait fedimint_core::db::IDatabase

source ·
pub trait IDatabase: Debug + MaybeSend + MaybeSync + 'static {
    // Required methods
    fn begin_transaction<'a, 'async_trait>(
        &'a self,
    ) -> Pin<Box<dyn Future<Output = Box<dyn IDatabaseTransaction + 'a>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait;
    fn register<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn notify<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn prefix_len(&self) -> usize;
    fn checkpoint(&self, backup_path: &Path) -> Result<()>;
}
Expand description

A database that on top of a raw database operation, implements key notification system.

Required Methods§

source

fn begin_transaction<'a, 'async_trait>( &'a self, ) -> Pin<Box<dyn Future<Output = Box<dyn IDatabaseTransaction + 'a>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

Start a database transaction

source

fn register<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Register (and wait) for key updates

source

fn notify<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Notify about key update (creation, modification, deletion)

source

fn prefix_len(&self) -> usize

The prefix len of this database instance

source

fn checkpoint(&self, backup_path: &Path) -> Result<()>

Checkpoints the database to a backup directory

Implementations on Foreign Types§

source§

impl<T> IDatabase for Arc<T>
where T: IDatabase + ?Sized,

source§

fn begin_transaction<'a, 'async_trait>( &'a self, ) -> Pin<Box<dyn Future<Output = Box<dyn IDatabaseTransaction + 'a>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait,

source§

fn register<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn notify<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn prefix_len(&self) -> usize

source§

fn checkpoint(&self, backup_path: &Path) -> Result<()>

Implementors§

source§

impl<Inner> IDatabase for PrefixDatabase<Inner>
where Inner: Debug + MaybeSend + MaybeSync + 'static + IDatabase,

source§

impl<RawDatabase: IRawDatabase + MaybeSend + 'static> IDatabase for BaseDatabase<RawDatabase>