pub struct Ndb { /* private fields */ }Expand description
A nostrdb context. Construct one of these with Ndb::new.
Implementations§
Source§impl Ndb
impl Ndb
Sourcepub fn new(db_dir: &str, config: &Config) -> Result<Ndb, Error>
pub fn new(db_dir: &str, config: &Config) -> Result<Ndb, Error>
Construct a new nostrdb context. Takes a directory where the database is/will be located and a nostrdb config.
Sourcepub fn process_event_with(
&self,
json: &str,
meta: IngestMetadata,
) -> Result<(), Error>
pub fn process_event_with( &self, json: &str, meta: IngestMetadata, ) -> Result<(), Error>
Ingest a relay or client sent event, with optional relay metadata. This function returns immediately and doesn’t provide any information on if ingestion was successful or not.
Sourcepub fn process_event(&self, json: &str) -> Result<(), Error>
pub fn process_event(&self, json: &str) -> Result<(), Error>
Ingest a relay-sent event in the form ["EVENT","subid", {"id:"...}]
This function returns immediately and doesn’t provide any information on
if ingestion was successful or not.
Sourcepub fn process_client_event(&self, json: &str) -> Result<(), Error>
pub fn process_client_event(&self, json: &str) -> Result<(), Error>
Ingest a client-sent event in the form ["EVENT", {"id:"...}]
This function returns immediately and doesn’t provide any information on
if ingestion was successful or not.
pub fn query<'a>( &self, txn: &'a Transaction, filters: &[Filter], max_results: i32, ) -> Result<Vec<QueryResult<'a>>, Error>
pub fn subscription_count(&self) -> u32
pub fn unsubscribe(&mut self, sub: Subscription) -> Result<(), Error>
pub fn subscribe(&self, filters: &[Filter]) -> Result<Subscription, Error>
pub fn poll_for_notes(&self, sub: Subscription, max_notes: u32) -> Vec<NoteKey>
pub async fn wait_for_notes( &self, sub_id: Subscription, max_notes: u32, ) -> Result<Vec<NoteKey>, Error>
pub fn get_profile_by_key<'a>( &self, transaction: &'a Transaction, key: ProfileKey, ) -> Result<ProfileRecord<'a>, Error>
pub fn get_profile_by_pubkey<'a>( &self, transaction: &'a Transaction, id: &[u8; 32], ) -> Result<ProfileRecord<'a>, Error>
pub fn get_note_metadata<'a>( &self, txn: &'a Transaction, id: &[u8; 32], ) -> Result<NoteMetadata<'a>, Error>
pub fn get_notekey_by_id( &self, txn: &Transaction, id: &[u8; 32], ) -> Result<NoteKey, Error>
pub fn get_profilekey_by_pubkey( &self, txn: &Transaction, pubkey: &[u8; 32], ) -> Result<ProfileKey, Error>
pub fn get_blocks_by_key<'a>( &self, txn: &'a Transaction, note_key: NoteKey, ) -> Result<Blocks<'a>, Error>
pub fn get_note_by_key<'a>( &self, transaction: &'a Transaction, note_key: NoteKey, ) -> Result<Note<'a>, Error>
Sourcepub fn get_note_by_id<'a>(
&self,
transaction: &'a Transaction,
id: &[u8; 32],
) -> Result<Note<'a>, Error>
pub fn get_note_by_id<'a>( &self, transaction: &'a Transaction, id: &[u8; 32], ) -> Result<Note<'a>, Error>
Get a note from the database. Takes a Transaction and a 32-byte Note Id
pub fn search_profile<'a>( &self, transaction: &'a Transaction, search: &str, limit: u32, ) -> Result<Vec<&'a [u8; 32]>, Error>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ndb
impl RefUnwindSafe for Ndb
impl Send for Ndb
impl Sync for Ndb
impl Unpin for Ndb
impl UnwindSafe for Ndb
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more