pub trait NostrDatabase: AsyncTraitDeps {
    type Err: From<DatabaseError> + Into<DatabaseError>;

Show 16 methods // 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, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn bulk_import<'life0, 'async_trait>( &'life0 self, events: BTreeSet<Event> ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn has_event_already_been_saved<'life0, 'life1, 'async_trait>( &'life0 self, event_id: &'life1 EventId ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn has_event_already_been_seen<'life0, 'life1, 'async_trait>( &'life0 self, event_id: &'life1 EventId ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn has_event_id_been_deleted<'life0, 'life1, 'async_trait>( &'life0 self, event_id: &'life1 EventId ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn has_coordinate_been_deleted<'life0, 'life1, 'async_trait>( &'life0 self, coordinate: &'life1 Coordinate, timestamp: Timestamp ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn event_id_seen<'life0, 'async_trait>( &'life0 self, event_id: EventId, relay_url: Url ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn event_seen_on_relays<'life0, 'async_trait>( &'life0 self, event_id: EventId ) -> Pin<Box<dyn Future<Output = Result<Option<HashSet<Url>>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn event_by_id<'life0, 'async_trait>( &'life0 self, event_id: EventId ) -> Pin<Box<dyn Future<Output = Result<Event, Self::Err>> + 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, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn query<'life0, 'async_trait>( &'life0 self, filters: Vec<Filter>, order: Order ) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn event_ids_by_filters<'life0, 'async_trait>( &'life0 self, filters: Vec<Filter>, order: Order ) -> Pin<Box<dyn Future<Output = Result<Vec<EventId>, Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn negentropy_items<'life0, 'async_trait>( &'life0 self, filter: Filter ) -> Pin<Box<dyn Future<Output = Result<Vec<(EventId, Timestamp)>, Self::Err>> + 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<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn wipe<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Nostr Database

Required Associated Types§

Required Methods§

source

fn backend(&self) -> Backend

Name of the backend database used (ex. rocksdb, lmdb, sqlite, indexeddb, …)

source

fn save_event<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 Event ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save Event into store

Return true if event was successfully saved into database.

This method assume that Event was already verified

source

fn bulk_import<'life0, 'async_trait>( &'life0 self, events: BTreeSet<Event> ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Bulk import events into database

This method assume that Event was already verified

source

fn has_event_already_been_saved<'life0, 'life1, 'async_trait>( &'life0 self, event_id: &'life1 EventId ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if Event has already been saved

source

fn has_event_already_been_seen<'life0, 'life1, 'async_trait>( &'life0 self, event_id: &'life1 EventId ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if EventId has already been seen

source

fn has_event_id_been_deleted<'life0, 'life1, 'async_trait>( &'life0 self, event_id: &'life1 EventId ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if EventId has been deleted

source

fn has_coordinate_been_deleted<'life0, 'life1, 'async_trait>( &'life0 self, coordinate: &'life1 Coordinate, timestamp: Timestamp ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if event with Coordinate has been deleted before Timestamp

source

fn event_id_seen<'life0, 'async_trait>( &'life0 self, event_id: EventId, relay_url: Url ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set EventId as seen by relay

Useful for NIP65 (aka gossip)

source

fn event_seen_on_relays<'life0, 'async_trait>( &'life0 self, event_id: EventId ) -> Pin<Box<dyn Future<Output = Result<Option<HashSet<Url>>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get list of relays that have seen the EventId

source

fn event_by_id<'life0, 'async_trait>( &'life0 self, event_id: EventId ) -> Pin<Box<dyn Future<Output = Result<Event, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get Event by EventId

source

fn count<'life0, 'async_trait>( &'life0 self, filters: Vec<Filter> ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Err>> + 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.

source

fn query<'life0, 'async_trait>( &'life0 self, filters: Vec<Filter>, order: Order ) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Query store with filters

source

fn event_ids_by_filters<'life0, 'async_trait>( &'life0 self, filters: Vec<Filter>, order: Order ) -> Pin<Box<dyn Future<Output = Result<Vec<EventId>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get event IDs by filters

source

fn negentropy_items<'life0, 'async_trait>( &'life0 self, filter: Filter ) -> Pin<Box<dyn Future<Output = Result<Vec<(EventId, Timestamp)>, Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get negentropy items

source

fn delete<'life0, 'async_trait>( &'life0 self, filter: Filter ) -> Pin<Box<dyn Future<Output = Result<(), Self::Err>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete all events that match the Filter

source

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

Wipe all data

Implementors§