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
impl Clone for MemoryStore
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§impl Files for MemoryStore
impl Files for MemoryStore
Source§fn write_file(&self, name: &str, bytes: &[u8]) -> Result<()>
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<()>
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>>
fn read_file(&self, name: &str) -> Result<Vec<u8>>
The file
name; io::ErrorKind::NotFound when there is none.Source§impl Store for MemoryStore
impl Store for MemoryStore
Source§fn read_log(&self, name: &str) -> Result<Vec<u8>>
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>
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>
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.Auto Trait Implementations§
impl Freeze for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl UnwindSafe for MemoryStore
Blanket Implementations§
Source§impl<S> AsyncStore for S
impl<S> AsyncStore for S
Source§fn read_log_async(
&self,
name: &str,
) -> impl Future<Output = Result<Vec<u8>, Error>> + WasmCompatSend
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
fn append_log_async( &self, name: &str, len: u64, bytes: &[u8], ) -> impl Future<Output = Result<(), LogWriteError>> + WasmCompatSend
Source§fn replace_log_async(
&self,
name: &str,
len: u64,
bytes: &[u8],
) -> impl Future<Output = Result<(), LogWriteError>> + WasmCompatSend
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
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
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more