pub trait NostrDatabase:
Any
+ Debug
+ Send
+ Sync {
// Required methods
fn backend(&self) -> &'static str;
fn features(&self) -> Features;
fn save_event<'a>(
&'a self,
event: &'a Event,
) -> Pin<Box<dyn Future<Output = Result<SaveEventStatus, Error>> + Send + 'a>>;
fn check_id<'a>(
&'a self,
event_id: &'a EventId,
) -> Pin<Box<dyn Future<Output = Result<DatabaseEventStatus, Error>> + Send + 'a>>;
fn event_by_id<'a>(
&'a self,
event_id: &'a EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, Error>> + Send + 'a>>;
fn count(
&self,
filter: Filter,
) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + '_>>;
fn query(
&self,
filter: Filter,
) -> Pin<Box<dyn Future<Output = Result<BTreeSet<Event>, Error>> + Send + '_>>;
fn delete(
&self,
filter: Filter,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
fn wipe(
&self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
// Provided method
fn negentropy_items(
&self,
filter: Filter,
) -> Pin<Box<dyn Future<Output = Result<Vec<(EventId, Timestamp)>, Error>> + Send + '_>> { ... }
}Expand description
Nostr (Events) Database
Required Methods§
Sourcefn save_event<'a>(
&'a self,
event: &'a Event,
) -> Pin<Box<dyn Future<Output = Result<SaveEventStatus, Error>> + Send + 'a>>
fn save_event<'a>( &'a self, event: &'a Event, ) -> Pin<Box<dyn Future<Output = Result<SaveEventStatus, Error>> + Send + 'a>>
Sourcefn check_id<'a>(
&'a self,
event_id: &'a EventId,
) -> Pin<Box<dyn Future<Output = Result<DatabaseEventStatus, Error>> + Send + 'a>>
fn check_id<'a>( &'a self, event_id: &'a EventId, ) -> Pin<Box<dyn Future<Output = Result<DatabaseEventStatus, Error>> + Send + 'a>>
Check event status by ID
Check if the event is saved, deleted or not existent.
Sourcefn event_by_id<'a>(
&'a self,
event_id: &'a EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, Error>> + Send + 'a>>
fn event_by_id<'a>( &'a self, event_id: &'a EventId, ) -> Pin<Box<dyn Future<Output = Result<Option<Event>, Error>> + Send + 'a>>
Sourcefn count(
&self,
filter: Filter,
) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + '_>>
fn count( &self, filter: Filter, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + '_>>
Count the number of events found with Filter.
Use Filter::new() or Filter::default() to count all events.
Sourcefn query(
&self,
filter: Filter,
) -> Pin<Box<dyn Future<Output = Result<BTreeSet<Event>, Error>> + Send + '_>>
fn query( &self, filter: Filter, ) -> Pin<Box<dyn Future<Output = Result<BTreeSet<Event>, Error>> + Send + '_>>
Query stored events.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".