pub trait Store: Files {
// Required methods
fn logs(&self) -> Result<Vec<String>>;
fn read_log(&self, name: &str) -> Result<Vec<u8>>;
fn append_log(
&self,
name: &str,
len: u64,
bytes: &[u8],
) -> Result<(), LogWriteError>;
fn replace_log(
&self,
name: &str,
len: u64,
bytes: &[u8],
) -> Result<(), LogWriteError>;
fn destroy(&self) -> Result<()>;
}Expand description
Where a session is kept: its Files, with the content-addressed
blobs its messages name under blobs/, and a log per agent plus the
session’s own, appended to and read whole. Log names are one part of a
name (check_name without /).
Required Methods§
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".