Skip to main content

MemoryVault

Struct MemoryVault 

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

RAM-only vault: nothing touches disk and everything is lost on restart.

Implementations§

Source§

impl MemoryVault

Source

pub fn len(&self) -> usize

How many values it holds.

Source

pub fn is_empty(&self) -> bool

True if it holds no values.

Source

pub fn oldest_created_at(&self) -> Option<i64>

Unix seconds when the oldest value it holds was added.

Source

pub fn clear(&self)

Forgets every value. Numbers already handed out are never given to another value, so an old placeholder can’t restore to the wrong one.

Source

pub fn adopt(&self, from: &ScopeId, into: &ScopeId) -> bool

Copies every value of from into into under the same numbers, so placeholders made in from mean the same in into. Only done while into has never handed out or reserved a number; otherwise copies nothing and returns false.

Trait Implementations§

Source§

impl Default for MemoryVault

Source§

fn default() -> Self

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

impl Vault for MemoryVault

Source§

fn get_or_create( &self, scope: &ScopeId, kind: &EntityKind, value: &str, ) -> Result<u64, VaultError>

Returns the placeholder number for value, creating one if needed. The same value of the same kind in the same scope always gets the same number.
Source§

fn lookup( &self, scope: &ScopeId, kind: &EntityKind, n: u64, ) -> Result<Option<String>, VaultError>

Returns the value behind placeholder number n, if this scope knows it.
Source§

fn reserve( &self, scope: &ScopeId, kind: &EntityKind, n: u64, ) -> Result<(), VaultError>

Makes sure number n is never handed out for a new value. Used for placeholder-shaped text the user wrote themselves.

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, !>

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.