Skip to main content

MemoryStorage

Struct MemoryStorage 

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

Origin-scoped key/value storage that lives and dies with the process.

Correct, just not durable. It is the right provider for a test, for a private-browsing mode, and for an embedder that has not wired a real one yet, and it is what the storage semantics are asserted against.

Note what it is not: a fallback that silently loses data. chuzz’s current JavaScript shim is an in-memory localStorage that a page cannot distinguish from a real one, so a site’s settings vanish on reload with no diagnostic. That is a property of the shim rather than of in-memory storage, but an embedder choosing this deliberately should still know it is choosing it.

Implementations§

Source§

impl MemoryStorage

Source

pub fn new() -> Self

Source

pub fn origin_count(&self) -> usize

How many origins hold anything. For tests that want to assert isolation rather than infer it.

Trait Implementations§

Source§

impl Default for MemoryStorage

Source§

fn default() -> MemoryStorage

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

impl StorageProvider for MemoryStorage

Source§

fn get(&self, origin: &OriginKey, key: &str) -> Option<String>

Source§

fn set( &self, origin: &OriginKey, key: &str, value: &str, ) -> Result<(), StorageError>

Source§

fn remove(&self, origin: &OriginKey, key: &str)

Source§

fn clear(&self, origin: &OriginKey)

Removes everything under origin, and nothing under any other.

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.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.