Trait nostr_database::NostrDatabase
source · 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§
sourcetype Err: From<DatabaseError> + Into<DatabaseError>
type Err: From<DatabaseError> + Into<DatabaseError>
Error
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, Self::Err>> + 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, Self::Err>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
sourcefn 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 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
sourcefn 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_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
sourcefn 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_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
sourcefn 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_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
sourcefn 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 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
sourcefn 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_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)
sourcefn 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_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
sourcefn 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 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,
sourcefn 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 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.
sourcefn 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 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
sourcefn 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 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
sourcefn 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 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