Skip to main content

MemoryStore

Struct MemoryStore 

Source
pub struct MemoryStore(/* private fields */);
Expand description

A session kept in memory, such as for tests or where there is no file system. Cloning shares the contents.

Trait Implementations§

Source§

impl Clone for MemoryStore

Source§

fn clone(&self) -> Self

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 Default for MemoryStore

Source§

fn default() -> Self

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

impl Files for MemoryStore

Source§

fn write_file(&self, name: &str, bytes: &[u8]) -> Result<()>

Replaces the file name with bytes, atomically: a reader sees the old content or the new.
Source§

fn append_file(&self, name: &str, bytes: &[u8]) -> Result<()>

Adds bytes at the end of the file name, which it creates when there is none.
Source§

fn read_file(&self, name: &str) -> Result<Vec<u8>>

The file name; io::ErrorKind::NotFound when there is none.
Source§

fn remove_file(&self, name: &str) -> Result<()>

Removes the file name; removing one that is not there succeeds.
Source§

fn files(&self) -> Result<Vec<String>>

The names of the files, in no particular order.
Source§

impl Store for MemoryStore

Source§

fn logs(&self) -> Result<Vec<String>>

The names of the logs, in no particular order.
Source§

fn read_log(&self, name: &str) -> Result<Vec<u8>>

The whole log name; io::ErrorKind::NotFound when there is none.
Source§

fn append_log( &self, name: &str, len: u64, bytes: &[u8], ) -> Result<(), LogWriteError>

Appends bytes to the log name if it is len bytes long now (0 when there is none, which it then starts); else LogWriteError::Changed, writing nothing. The check and the append are one step for every writer of the store, other processes included, so of two writers that read the log at the same length one appends and the other is refused. A log that shrank and grew back to exactly len bytes since it was read is not told apart; rig shrinks a log only by setting a torn last line aside, or by rewrite and Self::destroy, which are for a stopped session.
Source§

fn replace_log( &self, name: &str, len: u64, bytes: &[u8], ) -> Result<(), LogWriteError>

Replaces the log name with bytes, under the condition Self::append_log has, atomically and durably: a reader, and a crash or power loss, leave the old log or the new, never a part of either or an empty file; an append after it goes after the new bytes. Starts the log when there is none.
Source§

fn destroy(&self) -> Result<()>

Removes everything the store holds: logs and files. Idempotent: calling it again after a crash midway finishes the job.

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<S> AsyncStore for S
where S: Store + ?Sized,

Source§

fn read_log_async( &self, name: &str, ) -> impl Future<Output = Result<Vec<u8>, Error>> + WasmCompatSend

The whole log name.
Source§

fn append_log_async( &self, name: &str, len: u64, bytes: &[u8], ) -> impl Future<Output = Result<(), LogWriteError>> + WasmCompatSend

Appends bytes to the log name if it is len bytes long now (Store::append_log).
Source§

fn replace_log_async( &self, name: &str, len: u64, bytes: &[u8], ) -> impl Future<Output = Result<(), LogWriteError>> + WasmCompatSend

Replaces the log name with bytes if it is len bytes long now, atomically and durably (Store::replace_log).
Source§

fn read_file_async( &self, name: &str, ) -> impl Future<Output = Result<Vec<u8>, Error>> + WasmCompatSend

The file name.
Source§

fn write_file_async( &self, name: &str, bytes: &[u8], ) -> impl Future<Output = Result<(), Error>> + WasmCompatSend

Replaces the file name with bytes, atomically.
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> 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

Source§

type Output = T

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

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

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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