pub trait AsyncSliceWriter: Sized {
    type WriteFuture: Future<Output = (Self, Result<()>)> + Send;

    // Required methods
    fn write_at(self, offset: u64, data: Bytes) -> Self::WriteFuture;
    fn write_array_at<const N: usize>(
        self,
        offset: u64,
        bytes: [u8; N]
    ) -> Self::WriteFuture;
}
Expand description

A writer that can write a slice at a specified offset

Will extend the file if the offset is past the end of the file, just like posix and windows files do.

For external storage such as S3/R2, this might be implemented in terms of async http requests.

This is similar to the io interface of sqlite. See xWrite in https://www.sqlite.org/c3ref/io_methods.html

Required Associated Types§

source

type WriteFuture: Future<Output = (Self, Result<()>)> + Send

The future returned by write_at and write_array_at

This is state passing style, so the future will return Self in addition to the result of the write.

Required Methods§

source

fn write_at(self, offset: u64, data: Bytes) -> Self::WriteFuture

Write the entire Bytes at the given position

source

fn write_array_at<const N: usize>( self, offset: u64, bytes: [u8; N] ) -> Self::WriteFuture

Write an owned byte array at the given position

This is an alternative to write_at for small, fixed sized writes where converting to a Bytes would have too much overhead.

Implementors§

source§

impl<R: Write + Seek + Unpin + Send + 'static> AsyncSliceWriter for SyncIoAdapter<R>

source§

impl<W: AsyncWrite + AsyncSeek + Unpin + Send + Sync + 'static> AsyncSliceWriter for W

§

type WriteFuture = Pin<Box<dyn Future<Output = (W, Result<(), Error>)> + Send + 'static, Global>>