Trait nostr_database::NostrDatabase
source · pub trait NostrDatabase:
Debug
+ Send
+ Sync {
// Required methods
fn backend(&self) -> Backend;
fn save_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn check_id<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<DatabaseEventStatus, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn has_coordinate_been_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
coordinate: &'life1 Coordinate,
timestamp: &'life2 Timestamp,
) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn event_id_seen<'life0, 'async_trait>(
&'life0 self,
event_id: EventId,
relay_url: Url,
) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn event_seen_on_relays<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<HashSet<Url>>, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn event_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn count<'life0, 'async_trait>(
&'life0 self,
filters: Vec<Filter>,
) -> Pin<Box<dyn Future<Output = Result<usize, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn query<'life0, 'async_trait>(
&'life0 self,
filters: Vec<Filter>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'async_trait>(
&'life0 self,
filter: Filter,
) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn wipe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn negentropy_items<'life0, 'async_trait>(
&'life0 self,
filter: Filter,
) -> Pin<Box<dyn Future<Output = Result<Vec<(EventId, Timestamp)>, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Nostr Database
Required Methods§
sourcefn backend(&self) -> Backend
fn backend(&self) -> Backend
Name of the backend database used (ex. rocksdb, lmdb, sqlite, indexeddb, …)
sourcefn save_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_event<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
sourcefn check_id<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<DatabaseEventStatus, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn check_id<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<DatabaseEventStatus, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check event status by ID
Check if the event is saved, deleted or not existent.
sourcefn has_coordinate_been_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
coordinate: &'life1 Coordinate,
timestamp: &'life2 Timestamp,
) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn has_coordinate_been_deleted<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
coordinate: &'life1 Coordinate,
timestamp: &'life2 Timestamp,
) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Check if Coordinate has been deleted before a certain Timestamp
sourcefn event_id_seen<'life0, 'async_trait>(
&'life0 self,
event_id: EventId,
relay_url: Url,
) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn event_id_seen<'life0, 'async_trait>(
&'life0 self,
event_id: EventId,
relay_url: Url,
) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set EventId as seen by relay
Useful for NIP65 (aka gossip)
sourcefn event_seen_on_relays<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<HashSet<Url>>, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn event_seen_on_relays<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<HashSet<Url>>, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get list of relays that have seen the EventId
sourcefn event_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn event_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
event_id: &'life1 EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
sourcefn count<'life0, 'async_trait>(
&'life0 self,
filters: Vec<Filter>,
) -> Pin<Box<dyn Future<Output = Result<usize, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count<'life0, 'async_trait>(
&'life0 self,
filters: Vec<Filter>,
) -> Pin<Box<dyn Future<Output = Result<usize, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Count number of Event found by filters
Use Filter::new() or Filter::default() to count all events.
sourcefn query<'life0, 'async_trait>(
&'life0 self,
filters: Vec<Filter>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query<'life0, 'async_trait>(
&'life0 self,
filters: Vec<Filter>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, DatabaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Query store with filters