Skip to main content

WriteAt

Trait WriteAt 

Source
pub trait WriteAt {
    type Error: Error + MaybeSend + MaybeSync + 'static;

    // Required methods
    fn write_at(
        &self,
        offset: u64,
        buf: &[u8],
    ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend;
    fn set_len(
        &self,
        len: u64,
    ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend;

    // Provided method
    fn flush(&self) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend { ... }
}
Expand description

Async random-access write sink. Each leaf body is written at its absolute offset; when every offset is written the sink is whole. Not Send-bound so a single-threaded browser writable can implement it.

Required Associated Types§

Source

type Error: Error + MaybeSend + MaybeSync + 'static

Error returned by the sink operations.

Required Methods§

Source

fn write_at( &self, offset: u64, buf: &[u8], ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Write all of buf at offset.

Source

fn set_len( &self, len: u64, ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Pre-size the sink so every in-range write_at lands.

Provided Methods§

Source

fn flush(&self) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Flush buffered writes. Defaults to a no-op.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl WriteAt for File

Available on Unix and non-WebAssembly only.
Source§

type Error = Error

Source§

async fn write_at(&self, offset: u64, buf: &[u8]) -> Result<()>

Source§

async fn set_len(&self, len: u64) -> Result<()>

Source§

async fn flush(&self) -> Result<()>

Source§

impl WriteAt for Mutex<Vec<u8>>

Source§

type Error = Error

Source§

async fn write_at(&self, offset: u64, buf: &[u8]) -> Result<()>

Source§

async fn set_len(&self, len: u64) -> Result<()>

Source§

impl<T: WriteAt + ?Sized> WriteAt for &T

Source§

type Error = <T as WriteAt>::Error

Source§

fn write_at( &self, offset: u64, buf: &[u8], ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Source§

fn set_len( &self, len: u64, ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Source§

fn flush(&self) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Implementors§