Skip to main content

MemoryStorage

Struct MemoryStorage 

Source
pub struct MemoryStorage { /* private fields */ }
Expand description

A storage that keeps entries in memory for the lifetime of the process.

Used where nothing durable is available (no-std, or a cache root that can’t be opened). Entries do not survive a restart, so an imported bundle has to be imported again on the next run, which costs nothing but time.

Implementations§

Source§

impl MemoryStorage

Source

pub fn new(namespace: &str) -> Self

The in-memory storage for namespace, shared process-wide across every environment.

The environment-bound path uses in_environment instead, which isolates the entries per environment so a switch doesn’t serve the previous one’s data. This unscoped constructor is for explicit storages that aren’t tied to an environment (tests, benches).

Source

pub fn namespaces() -> Vec<NamespaceSummary>

Every namespace the active environment holds in memory.

Only the active environment’s entries are reported: the process-wide map also holds other environments’ entries and unscoped explicit storages, but a summary is always about the environment in effect right now.

Trait Implementations§

Source§

impl Clone for MemoryStorage

Source§

fn clone(&self) -> MemoryStorage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryStorage

Source§

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

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

impl Storage for MemoryStorage

Source§

fn get(&self, key: &[u8]) -> Option<Bytes>

The value stored under key, if any.
Source§

fn insert(&self, key: &[u8], value: Bytes, origin: Origin) -> Insertion

Stores value under key. See the trait contract for when the write is declined.
Source§

fn replace(&self, key: &[u8], value: Bytes, origin: Origin) -> Insertion

Stores value under key, overwriting whatever is there. Read more
Source§

fn scan(&self, visit: &mut dyn FnMut(&[u8], &[u8]))

Visits every entry of the namespace. Read more
Source§

fn purge(&self)

Deletes every entry of the namespace, durably. Read more
Source§

fn purge_key(&self, key: &[u8])

Deletes the entry under key, durably. Same failure contract as purge.
Source§

fn describe(&self) -> String

Human-readable location for log messages.
Source§

fn insert_many( &self, entries: &mut dyn Iterator<Item = (Bytes, Bytes)>, origin: Origin, ) -> InsertSummary

Stores many entries under the same rules as insert. Read more
Source§

fn loading(&self) -> bool

Whether the storage is still loading its content asynchronously. Entries become visible through get and scan once the load completes.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.