Trait random_access_storage::RandomAccess
source · pub trait RandomAccess {
type Error;
fn write(&mut self, offset: usize, data: &[u8]) -> Result<(), Self::Error>;
fn read(
&mut self,
offset: usize,
length: usize
) -> Result<Vec<u8>, Self::Error>;
fn read_to_writer(
&mut self,
offset: usize,
length: usize,
buf: &mut impl Write
) -> Result<(), Self::Error>;
fn del(&mut self, offset: usize, length: usize) -> Result<(), Self::Error>;
fn truncate(&mut self, length: usize) -> Result<(), Self::Error>;
fn len(&mut self) -> Result<usize, Self::Error>;
fn is_empty(&mut self) -> Result<bool, Self::Error>;
}
Expand description
The RandomAccess
trait allows for reading from and writing to a
randomly accessible storage of bytes.
Required Associated Types
Required Methods
sourcefn write(&mut self, offset: usize, data: &[u8]) -> Result<(), Self::Error>
fn write(&mut self, offset: usize, data: &[u8]) -> Result<(), Self::Error>
Write bytes at an offset to the backend.
sourcefn read(&mut self, offset: usize, length: usize) -> Result<Vec<u8>, Self::Error>
fn read(&mut self, offset: usize, length: usize) -> Result<Vec<u8>, Self::Error>
Read a sequence of bytes at an offset from the backend.
sourcefn read_to_writer(
&mut self,
offset: usize,
length: usize,
buf: &mut impl Write
) -> Result<(), Self::Error>
fn read_to_writer(
&mut self,
offset: usize,
length: usize,
buf: &mut impl Write
) -> Result<(), Self::Error>
Read a sequence of bytes at an offset from the backend.
sourcefn del(&mut self, offset: usize, length: usize) -> Result<(), Self::Error>
fn del(&mut self, offset: usize, length: usize) -> Result<(), Self::Error>
Delete a sequence of bytes at an offset from the backend.