Struct buffer::BufferRef [] [src]

pub struct BufferRef<'data, 'size> {
    // some fields omitted
}

A reference to an uninitialized or partially initialized byte buffer.

It keeps track of how many bytes (from the start of the buffer) are initialized.

Methods

impl<'d, 's> BufferRef<'d, 's>
[src]

fn new(buffer: &'d mut [u8], initialized: &'s mut usize) -> BufferRef<'d, 's>

Creates a buffer reference from the buffer and a pointer where the length should be written to.

Important: initialized must initially be zero.

unsafe fn advance(&mut self, num_bytes: usize)

Advances the split of initialized/uninitialized data by num_bytes to the right.

fn extend<I>(&mut self, bytes: I) -> Result<()CapacityError> where I: Iterator<Item=u8>

Writes the bytes yielded by the bytes iterator into the buffer.

If the iterator yields more bytes than the buffer can contain, a CapacityError is returned.

fn write(&mut self, bytes: &[u8]) -> Result<()CapacityError>

Writes the byte slice into the buffer.

If the slice contains more bytes than the buffer can contain, a CapacityError is returned.

unsafe fn uninitialized_mut(&mut self) -> &mut [u8]

Returns the uninitialized part of the buffer.

fn initialized(self) -> &'d [u8]

Consumes the (mutable) buffer reference to produce a slice of the initialized data that is independent from the BufferRef instance.

fn remaining(&self) -> usize

Returns the amount of uninitialized bytes that are left.

Trait Implementations

impl<'r, 'd, 's> Buffer<'d> for &'r mut BufferRef<'d, 's>
[src]

type Intermediate = BufferRefBuffer<'r, 'd, 's>

Intermediate result of converting the T: Buffer into a BufferRef.

fn to_to_buffer_ref(self) -> Self::Intermediate

Converts the T: Buffer into the intermediate step to BufferRef.