Struct MemoryStore
pub struct MemoryStore { /* private fields */ }
Available on crate feature
kad
only.Expand description
In-memory implementation of a RecordStore
.
Implementations§
§impl MemoryStore
impl MemoryStore
pub fn new(local_id: PeerId) -> MemoryStore
pub fn new(local_id: PeerId) -> MemoryStore
Creates a new MemoryRecordStore
with a default configuration.
pub fn with_config(local_id: PeerId, config: MemoryStoreConfig) -> MemoryStore
pub fn with_config(local_id: PeerId, config: MemoryStoreConfig) -> MemoryStore
Creates a new MemoryRecordStore
with the given configuration.
Trait Implementations§
§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>>
§fn records(&self) -> <MemoryStore as RecordStore>::RecordsIter<'_>
fn records(&self) -> <MemoryStore as RecordStore>::RecordsIter<'_>
Gets an iterator over all (value-) records currently stored.
§fn add_provider(&mut self, record: ProviderRecord) -> Result<(), Error>
fn add_provider(&mut self, record: ProviderRecord) -> Result<(), Error>
Adds a provider record to the store. Read more
§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.
§fn provided(&self) -> <MemoryStore as RecordStore>::ProvidedIter<'_>
fn provided(&self) -> <MemoryStore as RecordStore>::ProvidedIter<'_>
Gets an iterator over all stored provider records for which the
node owning the store is itself the provider.
§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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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