Struct BufferRef

Source
pub struct BufferRef<'buffer, T> { /* private fields */ }
Expand description

A reference to a Buffer, which is meant be a subset of the functionality offered by the fully owned buffer.

For example, it neither allows reading from the unfilled region, nor swapping out the buffer pointed to, with anything else.

Implementations§

Source§

impl<'buffer, T> BufferRef<'buffer, T>

Source

pub fn items_filled(&self) -> usize

Source

pub fn by_ref(&mut self) -> BufferRef<'_, T>

Reborrow the inner buffer, getting a buffer reference with a shorter lifetime.

Source§

impl<'buffer, T> BufferRef<'buffer, T>
where T: Initialize,

Source

pub fn remaining(&self) -> usize

Source

pub fn unfilled_parts( &mut self, ) -> (&mut [T::Item], &mut [MaybeUninit<T::Item>])

Source

pub unsafe fn unfilled_mut(&mut self) -> &mut [MaybeUninit<T::Item>]

Get a mutable and possibly-uninitialized reference to all of the buffer.

§Safety

The caller must not allow safe code to de-initialize the resulting slice.

Source

pub unsafe fn advance(&mut self, count: usize)

Advance the counter of the number of items filled.

The number of items that are initialized is also updated accordingly, so that the number of items initialized is always greater than or equal to the number of items filled.

§Safety

The caller must uphold the initialization invariant.

Source

pub unsafe fn advance_all(&mut self)

Advance the counter of the number of items filled, and the number of items initialized, to the end of the buffer.

§Safety

The caller must uphold the initialization invariant.

Source

pub fn revert_to_start(&mut self)

Source

pub fn fill_by_repeating(&mut self, item: T::Item)
where T::Item: Copy,

Source

pub fn append(&mut self, slice: &[T::Item])
where T::Item: Copy,

Source§

impl<T> BufferRef<'_, T>
where T: Initialize<Item = u8>,

Source

pub fn fill_by_zeroing(&mut self)

Auto Trait Implementations§

§

impl<'buffer, T> Freeze for BufferRef<'buffer, T>

§

impl<'buffer, T> RefUnwindSafe for BufferRef<'buffer, T>
where T: RefUnwindSafe,

§

impl<'buffer, T> Send for BufferRef<'buffer, T>
where T: Send,

§

impl<'buffer, T> Sync for BufferRef<'buffer, T>
where T: Sync,

§

impl<'buffer, T> Unpin for BufferRef<'buffer, T>

§

impl<'buffer, T> !UnwindSafe for BufferRef<'buffer, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.