Trait io::BlockWriter

source ·
pub trait BlockWriter: BlockIo {
    // Required methods
    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§

source

fn write_blocks( &mut self, buffer: &[u8], block_offset: usize ) -> Result<usize, IoError>

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.

source

fn flush(&mut self) -> Result<(), IoError>

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

Implementations on Foreign Types§

source§

impl<W> BlockWriter for Box<W>where W: BlockWriter + ?Sized,

source§

fn write_blocks( &mut self, buffer: &[u8], block_offset: usize ) -> Result<usize, IoError>

source§

fn flush(&mut self) -> Result<(), IoError>

source§

impl<W> BlockWriter for &mut Wwhere W: BlockWriter + ?Sized,

source§

fn write_blocks( &mut self, buffer: &[u8], block_offset: usize ) -> Result<usize, IoError>

source§

fn flush(&mut self) -> Result<(), IoError>

Implementors§

source§

impl<'io, IO, L, B> BlockWriter for &LockableIo<'io, IO, L, B>where IO: BlockWriter + 'io + ?Sized, L: for<'a> Lockable<'a, IO> + ?Sized, B: Borrow<L>,

source§

impl<'io, IO, L, B> BlockWriter for LockableIo<'io, IO, L, B>where IO: BlockWriter + 'io + ?Sized, L: for<'a> Lockable<'a, IO> + ?Sized, B: Borrow<L>,

source§

impl<IO> BlockWriter for ReaderWriter<IO>where IO: BlockWriter,

source§

impl<IO> BlockWriter for Writer<IO>where IO: BlockWriter,

source§

impl<RW> BlockWriter for ByteReaderWriterWrapper<RW>where RW: BlockReader + BlockWriter,

source§

impl<RW> BlockWriter for ByteWriterWrapper<RW>where RW: BlockReader + BlockWriter,