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 fetch_notes_by_tags<'life0, 'life1, 'async_trait>(
&'life0 self,
tags: &'life1 [NoteTag],
cursor: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredNote>, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: '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§
Sourcefn connect<'async_trait>(
config: DatabaseConfig,
metrics: MetricsDatabase,
) -> Pin<Box<dyn Future<Output = Result<Self, DatabaseError>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
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
Sourcefn 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 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
Sourcefn 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 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
Fetch notes matching ANY of a set of tags, in a single DB snapshot.
This is the preferred multi-tag query — running per-tag queries back to back reopens a race where a concurrent INSERT can land between two per-tag queries and get leapfrogged by the cursor advance.
Sourcefn 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 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
Sourcefn 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 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
Sourcefn 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,
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
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".