Trait fuse_backend_rs::api::filesystem::ZeroCopyWriter

source ·
pub trait ZeroCopyWriter: Write {
    // Required methods
    fn write_from(
        &mut self,
        f: &mut dyn FileReadWriteVolatile,
        count: usize,
        off: u64,
    ) -> Result<usize>;
    fn available_bytes(&self) -> usize;

    // Provided methods
    fn write_all_from(
        &mut self,
        f: &mut dyn FileReadWriteVolatile,
        count: usize,
        off: u64,
    ) -> Result<()> { ... }
    fn copy_to_end(
        &mut self,
        f: &mut dyn FileReadWriteVolatile,
        off: u64,
    ) -> Result<usize> { ... }
}
Expand description

A trait for directly copying data from a File into the fuse transport without first storing it in an intermediate buffer.

Required Methods§

source

fn write_from( &mut self, f: &mut dyn FileReadWriteVolatile, count: usize, off: u64, ) -> Result<usize>

Copies at most count bytes from f at offset off directly into self without storing it in any intermediate buffers. If the return value is Ok(n) then it must be guaranteed that 0 <= n <= count. If n is 0, then it can indicate one of 3 possibilities:

  1. There is no more data left in f.
  2. There is no more space in self.
  3. count was 0.
§Errors

If any error is returned then the implementation must guarantee that no bytes were copied from f. If the underlying read from f returns 0 then the implementation must return an error of the kind io::ErrorKind::UnexpectedEof.

source

fn available_bytes(&self) -> usize

Return number of bytes available for writing.

Useful for buffer fixed writers, such as FuseDevWriter, VirtioFsWriter

Provided Methods§

source

fn write_all_from( &mut self, f: &mut dyn FileReadWriteVolatile, count: usize, off: u64, ) -> Result<()>

Copies exactly count bytes of data from f at offset off into self. off + count must be less than u64::MAX.

§Errors

If an error is returned then the number of bytes copied from self is unspecified but it well never be more than count.

source

fn copy_to_end( &mut self, f: &mut dyn FileReadWriteVolatile, off: u64, ) -> Result<usize>

Copies all remaining bytes from f at offset off into self. Equivalent to repeatedly calling write_from until it returns either Ok(0) or a non-ErrorKind::Interrupted error.

§Errors

If an error is returned then the number of bytes copied from f is unspecified.

Implementations on Foreign Types§

source§

impl ZeroCopyWriter for File

source§

fn write_from( &mut self, f: &mut dyn FileReadWriteVolatile, count: usize, off: u64, ) -> Result<usize>

source§

fn available_bytes(&self) -> usize

Implementors§