Struct libp2p_kad::record::store::MemoryStore
source · pub struct MemoryStore { /* private fields */ }
Expand description
In-memory implementation of a RecordStore
.
Implementations§
source§impl MemoryStore
impl MemoryStore
sourcepub fn new(local_id: PeerId) -> Self
pub fn new(local_id: PeerId) -> Self
Creates a new MemoryRecordStore
with a default configuration.
sourcepub fn with_config(local_id: PeerId, config: MemoryStoreConfig) -> Self
pub fn with_config(local_id: PeerId, config: MemoryStoreConfig) -> Self
Creates a new MemoryRecordStore
with the given configuration.
Trait Implementations§
source§impl RecordStore for MemoryStore
impl RecordStore for MemoryStore
type RecordsIter<'a> = Map<Values<'a, Key, Record>, fn(_: &'a Record) -> Cow<'a, Record>>
type ProvidedIter<'a> = Map<Iter<'a, ProviderRecord>, fn(_: &'a ProviderRecord) -> Cow<'a, ProviderRecord>>
source§fn get(&self, k: &Key) -> Option<Cow<'_, Record>>
fn get(&self, k: &Key) -> Option<Cow<'_, Record>>
Gets a record from the store, given its key.
source§fn records(&self) -> Self::RecordsIter<'_>
fn records(&self) -> Self::RecordsIter<'_>
Gets an iterator over all (value-) records currently stored.
source§fn add_provider(&mut self, record: ProviderRecord) -> Result<()>
fn add_provider(&mut self, record: ProviderRecord) -> Result<()>
Adds a provider record to the store. Read more
source§fn providers(&self, key: &Key) -> Vec<ProviderRecord>
fn providers(&self, key: &Key) -> Vec<ProviderRecord>
Gets a copy of the stored provider records for the given key.
source§fn provided(&self) -> Self::ProvidedIter<'_>
fn provided(&self) -> Self::ProvidedIter<'_>
Gets an iterator over all stored provider records for which the
node owning the store is itself the provider.
source§fn remove_provider(&mut self, key: &Key, provider: &PeerId)
fn remove_provider(&mut self, key: &Key, provider: &PeerId)
Removes a provider record from the store.
Auto Trait Implementations§
impl Freeze for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnwindSafe for MemoryStore
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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