pub struct Metadata<E: Clock + Storage + Metrics, K: Array, V: Codec> { /* private fields */ }
Expand description
Implementation of Metadata storage.
Implementations§
Source§impl<E: Clock + Storage + Metrics, K: Array, V: Codec> Metadata<E, K, V>
impl<E: Clock + Storage + Metrics, K: Array, V: Codec> Metadata<E, K, V>
Sourcepub async fn init(context: E, cfg: Config<V::Cfg>) -> Result<Self, Error>
pub async fn init(context: E, cfg: Config<V::Cfg>) -> Result<Self, Error>
Initialize a new Metadata instance.
Sourcepub fn get_mut(&mut self, key: &K) -> Option<&mut V>
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
Get a mutable reference to a value from Metadata (if it exists).
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear all values from Metadata. The new state will not be persisted until Self::sync is called.
Sourcepub fn put(&mut self, key: K, value: V)
pub fn put(&mut self, key: K, value: V)
Put a value into Metadata.
If the key already exists, the value will be overwritten. The value stored will not be persisted until Self::sync is called.
Sourcepub async fn put_sync(&mut self, key: K, value: V) -> Result<(), Error>
pub async fn put_sync(&mut self, key: K, value: V) -> Result<(), Error>
Perform a Self::put and Self::sync in a single operation.
Sourcepub fn keys<'a>(
&'a self,
prefix: Option<&'a [u8]>,
) -> impl Iterator<Item = &'a K> + 'a
pub fn keys<'a>( &'a self, prefix: Option<&'a [u8]>, ) -> impl Iterator<Item = &'a K> + 'a
Iterate over all keys in metadata, optionally filtered by prefix.
If a prefix is provided, only keys that start with the prefix bytes will be returned.
Sourcepub fn remove_prefix(&mut self, prefix: &[u8])
pub fn remove_prefix(&mut self, prefix: &[u8])
Remove all keys that start with the given prefix.
Auto Trait Implementations§
impl<E, K, V> Freeze for Metadata<E, K, V>
impl<E, K, V> RefUnwindSafe for Metadata<E, K, V>
impl<E, K, V> Send for Metadata<E, K, V>where
V: Send,
impl<E, K, V> Sync for Metadata<E, K, V>where
V: Sync,
impl<E, K, V> Unpin for Metadata<E, K, V>
impl<E, K, V> UnwindSafe for Metadata<E, K, V>where
E: UnwindSafe,
K: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe,
<E as Storage>::Blob: UnwindSafe,
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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