Struct buffer::BufferRef [−][src]
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]
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.
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]
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.
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
.
fn to_to_buffer_ref(self) -> Self::Intermediate
[src]
fn cap_at(self, len: usize) -> CapAt<'data, Self> where
Self: Sized,
[src]
Self: Sized,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,