[][src]Trait genio::bufio::BufWrite

pub unsafe trait BufWrite: Write {
    fn request_buffer(&mut self) -> Result<*mut [u8], Self::WriteError>;
unsafe fn submit_buffer(&mut self, size: usize); fn write_byte(&mut self, byte: u8) -> Result<(), Self::WriteError> { ... } }

When writing, it might be better to serialize directly into a buffer. This trait allows such situation.

This triat is unsafe because it optimizes buffers to not require zeroing.

Required methods

fn request_buffer(&mut self) -> Result<*mut [u8], Self::WriteError>

Requests buffer for writing. The buffer is represented as a pointer because it may contain uninitialized memory - only writing is allowed. The pointer must not outlive Self!

The returned slice must always be non-empty. If non-emty slice can't be returned, Err must be returned instead. If the underlying writer is full, it has to flush the buffer.

unsafe fn submit_buffer(&mut self, size: usize)

Tells the buf writer that size bytes were written into buffer.

The size must NOT be bigger by mistake!

Loading content...

Provided methods

fn write_byte(&mut self, byte: u8) -> Result<(), Self::WriteError>

Writes single byte. Since this is buffered, the operation will be efficient.

Loading content...

Implementations on Foreign Types

impl BufWrite for Vec<u8>[src]

impl<'a, W: BufWrite> BufWrite for &'a mut W[src]

impl<'a> BufWrite for &'a mut [u8][src]

Loading content...

Implementors

impl<W: Write, B: AsRawBuf> BufWrite for BufWriter<W, B>[src]

Loading content...