commonware_runtime

Trait Blob

Source
pub trait Blob:
    Send
    + Sync
    + 'static {
    // Required methods
    fn len(&self) -> impl Future<Output = Result<usize, Error>> + Send;
    fn read_at(
        &mut self,
        buf: &mut [u8],
        offset: usize,
    ) -> impl Future<Output = Result<usize, Error>> + Send;
    fn write_at(
        &mut self,
        buf: &[u8],
        offset: usize,
    ) -> impl Future<Output = Result<(), Error>> + Send;
    fn truncate(
        &mut self,
        len: usize,
    ) -> impl Future<Output = Result<(), Error>> + Send;
    fn sync(&mut self) -> impl Future<Output = Result<(), Error>> + Send;
    fn close(&mut self) -> impl Future<Output = Result<(), Error>> + Send;
}
Expand description

Interface to read and write to a blob.

Required Methods§

Source

fn len(&self) -> impl Future<Output = Result<usize, Error>> + Send

Get the length of the blob.

Source

fn read_at( &mut self, buf: &mut [u8], offset: usize, ) -> impl Future<Output = Result<usize, Error>> + Send

Read from the blob at the given offset.

Source

fn write_at( &mut self, buf: &[u8], offset: usize, ) -> impl Future<Output = Result<(), Error>> + Send

Write to the blob at the given offset.

Source

fn truncate( &mut self, len: usize, ) -> impl Future<Output = Result<(), Error>> + Send

Truncate the blob to the given length.

Source

fn sync(&mut self) -> impl Future<Output = Result<(), Error>> + Send

Ensure all pending data is durably persisted.

Source

fn close(&mut self) -> impl Future<Output = Result<(), Error>> + Send

Close the blob.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Blob for commonware_runtime::deterministic::Blob

Source§

impl Blob for commonware_runtime::tokio::Blob