Skip to main content

DatabaseBackend

Trait DatabaseBackend 

Source
pub trait DatabaseBackend: Send + Sync {
    // Required methods
    fn connect<'async_trait>(
        config: DatabaseConfig,
        metrics: MetricsDatabase,
    ) -> Pin<Box<dyn Future<Output = Result<Self, DatabaseError>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait;
    fn store_note<'life0, 'life1, 'async_trait>(
        &'life0 self,
        note: &'life1 StoredNote,
    ) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn fetch_notes<'life0, 'async_trait>(
        &'life0 self,
        tag: NoteTag,
        cursor: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredNote>, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_stats<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(u64, u64), DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cleanup_old_notes<'life0, 'async_trait>(
        &'life0 self,
        retention_days: u32,
    ) -> Pin<Box<dyn Future<Output = Result<u64, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn note_exists<'life0, 'async_trait>(
        &'life0 self,
        note_id: NoteId,
    ) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Database operations

Required Methods§

Source

fn connect<'async_trait>( config: DatabaseConfig, metrics: MetricsDatabase, ) -> Pin<Box<dyn Future<Output = Result<Self, DatabaseError>> + Send + 'async_trait>>
where Self: Sized + 'async_trait,

Connect to the database

Source

fn store_note<'life0, 'life1, 'async_trait>( &'life0 self, note: &'life1 StoredNote, ) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a new note

Source

fn fetch_notes<'life0, 'async_trait>( &'life0 self, tag: NoteTag, cursor: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredNote>, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch notes by tag

Source

fn get_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(u64, u64), DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get statistics about the database

Source

fn cleanup_old_notes<'life0, 'async_trait>( &'life0 self, retention_days: u32, ) -> Pin<Box<dyn Future<Output = Result<u64, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clean up old notes based on retention policy

Source

fn note_exists<'life0, 'async_trait>( &'life0 self, note_id: NoteId, ) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if a note exists

Implementors§