pub trait NativeLogStorage: Send + Sync {
// Required methods
fn read_chunk(
&self,
name: &str,
version: u64,
chunk: u64,
) -> Result<Option<Vec<u8>>, LogError>;
fn cas_chunk(
&self,
name: &str,
version: u64,
chunk: u64,
expected: Option<&[u8]>,
new: &[u8],
) -> Result<(), LogError>;
fn list_chunks(&self, name: &str) -> Result<Vec<(u64, u64)>, LogError>;
fn delete_all(&self, name: &str) -> Result<(), LogError>;
}Expand description
Synchronous byte store for chunked transaction-log objects.
Implementations usually adapt the same native storage system used for blobs
and roots. A database’s log for one lease version is a sequence of chunk
objects (name, version, chunk), each a run of framed records; a writer
appends to the highest chunk and rolls to the next once it fills, so no
single object grows without bound. Chunk 0 of a version is the whole-log
object earlier releases wrote, so existing logs read back as their chunk 0.
Required Methods§
Sourcefn read_chunk(
&self,
name: &str,
version: u64,
chunk: u64,
) -> Result<Option<Vec<u8>>, LogError>
fn read_chunk( &self, name: &str, version: u64, chunk: u64, ) -> Result<Option<Vec<u8>>, LogError>
Reads the encoded bytes for one (name, version, chunk) object.
§Errors
Returns an error when the native backend cannot read the chunk object or when backend data cannot be represented as log bytes.
Sourcefn cas_chunk(
&self,
name: &str,
version: u64,
chunk: u64,
expected: Option<&[u8]>,
new: &[u8],
) -> Result<(), LogError>
fn cas_chunk( &self, name: &str, version: u64, chunk: u64, expected: Option<&[u8]>, new: &[u8], ) -> Result<(), LogError>
Compare-and-swap writes encoded bytes for one (name, version, chunk)
object.
§Errors
Returns an error when the compare-and-swap fails, the native backend cannot publish the chunk object, or the backend reports invalid data.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".