pub struct MemStorage { /* private fields */ }
Expand description

The MemStorage struct is an in-memory-only implementation of the Storage trait, to be used in testing scenarios.

Implementations§

source§

impl MemStorage

source

pub fn new() -> Self

source

pub fn committed(&self) -> bool

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

Trait Implementations§

source§

impl Debug for MemStorage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for MemStorage

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Storage for MemStorage

source§

fn get_string<'a>(&'a self, key: &'a str) -> BoxFuture<'_, Option<String>>

Get a string from the backing store. Returns None if there is no value for the given key.

source§

fn get_int<'a>(&'a self, key: &'a str) -> BoxFuture<'_, Option<i64>>

Get an int from the backing store. Returns None if there is no value for the given key.

source§

fn get_bool<'a>(&'a self, key: &'a str) -> BoxFuture<'_, Option<bool>>

Get a boolean from the backing store. Returns None if there is no value for the given key.

source§

fn set_string<'a>( &'a mut self, key: &'a str, value: &'a str ) -> BoxFuture<'_, Result<(), Self::Error>>

Set a value to be stored in the backing store. The implementation should cache the value until the |commit()| fn is called, and then persist all cached values at that time.

source§

fn set_int<'a>( &'a mut self, key: &'a str, value: i64 ) -> BoxFuture<'_, Result<(), Self::Error>>

Set a value to be stored in the backing store. The implementation should cache the value until the |commit()| fn is called, and then persist all cached values at that time.

source§

fn set_bool<'a>( &'a mut self, key: &'a str, value: bool ) -> BoxFuture<'_, Result<(), Self::Error>>

Set a value to be stored in the backing store. The implementation should cache the value until the |commit()| fn is called, and then persist all cached values at that time.

source§

fn commit(&mut self) -> BoxFuture<'_, Result<(), Self::Error>>

Persist all cached values to storage.

§

type Error = StorageErrors

source§

fn remove<'a>( &'a mut self, key: &'a str ) -> BoxFuture<'_, Result<(), Self::Error>>

Remove the value for |key| from the backing store. The implementation should cache that the value has been removed until the |commit()| fn is called, and then persist all changes at that time. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> StorageExt for T
where T: Storage,

source§

fn set_option_int<'a>( &'a mut self, key: &'a str, value: Option<i64> ) -> BoxFuture<'_, Result<(), Self::Error>>

Set an Option to be stored in the backing store. The implementation should cache the value until the |commit()| fn is called, and then persist all cached values at that time. If the Option is None, the implementation should call |remove()| for the key.
source§

fn get_time<'a>(&'a self, key: &'a str) -> BoxFuture<'_, Option<SystemTime>>

Get a SystemTime from the backing store. Returns None if there is no value for the given key, or if the value for the key has a different type.
source§

fn set_time<'a>( &'a mut self, key: &'a str, value: impl Into<SystemTime> ) -> BoxFuture<'_, Result<(), Self::Error>>

Set a SystemTime to be stored in the backing store. The implementation should cache the value until the |commit()| fn is called, and then persist all cached values at that time. Note that submicrosecond will be dropped.
source§

fn remove_or_log<'a>(&'a mut self, key: &'a str) -> BoxFuture<'_, ()>

Remove the value for |key| from the backing store, log an error message on error.
source§

fn commit_or_log(&mut self) -> BoxFuture<'_, ()>

Persist all cached values to storage, log an error message on error.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Unless for T

source§

fn unless(self, option: Option<T>) -> T

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more