Skip to main content

Storage

Trait Storage 

Source
pub trait Storage: Send + Sync {
    // Required methods
    fn size(&self) -> u64;
    fn read(&self, start: u64, data: &mut [u8]);
    fn write(&mut self, start: u64, data: &[u8]);
    fn commit(&mut self, size: u64);

    // Provided methods
    fn write_vec(&mut self, start: u64, data: Vec<u8>) { ... }
    fn write_data(&mut self, start: u64, data: Data, off: usize, len: usize) { ... }
    fn write_u64(&mut self, start: u64, value: u64) { ... }
    fn read_u64(&self, start: u64) -> u64 { ... }
    fn clone(&self) -> Box<dyn Storage> { ... }
    fn wait_complete(&self) { ... }
}
Expand description

Storage interface - Storage is some kind of “file” storage.

read and write methods take a start which is a byte offset in the underlying file.

Required Methods§

Source

fn size(&self) -> u64

Get the size of the underlying storage. Note : this is valid initially and after a commit but is not defined after write is called.

Source

fn read(&self, start: u64, data: &mut [u8])

Read data.

Source

fn write(&mut self, start: u64, data: &[u8])

Write byte slice to storage.

Source

fn commit(&mut self, size: u64)

Finish write transaction, size is new size of underlying storage.

Provided Methods§

Source

fn write_vec(&mut self, start: u64, data: Vec<u8>)

Write byte Vec.

Source

fn write_data(&mut self, start: u64, data: Data, off: usize, len: usize)

Write Data slice.

Source

fn write_u64(&mut self, start: u64, value: u64)

Write u64.

Source

fn read_u64(&self, start: u64) -> u64

Read u64.

Source

fn clone(&self) -> Box<dyn Storage>

Clone. note: provided method panics.

Source

fn wait_complete(&self)

Wait until current writes are complete.

Implementors§