Struct buffer::BufferRef[][src]

pub struct BufferRef<'data, 'size> { /* 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.

Implementations

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

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

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

Important: initialized must initially be zero.

pub unsafe fn advance(&mut self, num_bytes: usize)[src]

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

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

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.

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

Writes the byte slice into the buffer.

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

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

Returns the uninitialized part of the buffer.

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

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

pub fn remaining(&self) -> usize[src]

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.

Auto Trait Implementations

impl<'data, 'size> RefUnwindSafe for BufferRef<'data, 'size>

impl<'data, 'size> Send for BufferRef<'data, 'size>

impl<'data, 'size> Sync for BufferRef<'data, 'size>

impl<'data, 'size> Unpin for BufferRef<'data, 'size>

impl<'data, 'size> !UnwindSafe for BufferRef<'data, 'size>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.