Trait io::BlockWriter

source ·
pub trait BlockWriter: BlockIo {
    fn write_blocks(
        &mut self,
        buffer: &[u8],
        block_offset: usize
    ) -> Result<usize, IoError>; fn flush(&mut self) -> Result<(), IoError>; }
Expand description

A trait that represents an I/O stream (e.g., an I/O device) that can be written to in blocks. The block size specifies the minimum granularity of each transfer, as given by the BlockIo::block_size() function.

A BlockWriter is not aware of the current block offset into the stream; thus, each write operation requires a starting offset: the number of blocks from the beginning of the I/O stream at which the write should start.

Required Methods§

Writes blocks of data from the given buffer to this writer.

The number of blocks written is dictated by the length of the given buffer.

Arguments
  • buffer: the buffer from which data will be written. The length of this buffer must be a multiple of the block size.
  • block_offset: the offset in number of blocks from the beginning of this writer.
Return

If successful, returns the number of blocks written to this writer. Otherwise, returns an error.

Flushes this entire writer’s output stream, ensuring all contents in intermediate buffers are fully written out.

Implementations on Foreign Types§

Implementors§