Struct uninit_tools::buffer::Buffer[][src]

pub struct Buffer<T> { /* fields omitted */ }

Implementations

impl<T> Buffer<T>[src]

pub const fn from_initializer(initializer: BufferInitializer<T>) -> Self[src]

Create a new buffer from an initializer.

pub const fn uninit(inner: T) -> Self[src]

Create a new buffer, defaulting to not being initialized, nor filled. Prefer new if the buffer is already initialized.

pub fn into_raw_parts(self) -> (BufferInitializer<T>, usize)[src]

Move out the buffer initializer, which contains the inner buffer and initialization cursor, and get the filledness cursor.

pub fn into_initializer(self) -> BufferInitializer<T>[src]

pub fn into_inner(self) -> T[src]

Move out the inner buffer, being uninitialized or initialized based on whatever it was when this buffer was constructed.

Use try_into_init if the buffer is initialized.

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

Get the number of items that are currently filled, within the buffer. Note that this is different from the number of initialized items; use items_initialized for that.

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

pub const fn initializer(&self) -> &BufferInitializer<T>[src]

pub fn initializer_mut(&mut self) -> &mut BufferInitializer<T>[src]

impl<T, Item> Buffer<AsUninit<T>> where
    T: Deref<Target = [Item]> + DerefMut + TrustedDeref
[src]

pub fn new(init: T) -> Self[src]

impl<T> Buffer<T> where
    T: Initialize
[src]

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

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

Get the number of items that may be filled before the buffer is full.

pub fn is_full(&self) -> bool[src]

Check whether the buffer is completely filled, and thus also initialized.

pub fn is_empty(&self) -> bool[src]

Check whether the buffer is empty. It can be partially or fully initialized however.

pub fn filled_part(&self) -> &[T::Item]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Retrieve a shared slice to the filled part of the buffer.

pub fn filled_part_mut(&mut self) -> &mut [T::Item]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Retrieve a mutable slice to the filled part of the buffer.

pub fn unfilled_part(&self) -> &[MaybeUninit<T::Item>]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Get a shared slice to the unfilled part, which may be uninitialized.

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Get a mutable reference to the unfilled part of the buffer, which may overlap with the initialized-but-nonfilled region.

Safety

Due to the possibility of an overlap between the part that is initialized and the part that is unfilled, the caller must ensure that the resulting slice is never used to deinitialize the buffer.

It is thus recommended to use append or fill_by_repeating instead, since those are the by far most common operations to do when initializing. However, code that requires interfacing with other APIs such as system calls, need to use this function.

If mutable access really is needed for the unfilled region in safe code, consider using all_parts_mut.

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

Borrow both the filled and unfilled parts immutably.

pub fn all_parts(&self) -> BufferParts<'_, T::Item>[src]

Borrow the filled part, the unfilled but initialized part, and the unfilled and uninitialized part.

pub fn all_parts_mut(&mut self) -> BufferPartsMut<'_, T::Item>[src]

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

Borrow both the filled and the unfilled parts, mutably.

Safety

This is unsafe as the uninit part may have items in it that are tracked to be initialized. It is hence the responsibility of the caller to ensure that the buffer is not deinitialized by writing MaybeUninit::uninit() to it.

pub fn unfilled_init_part(&self) -> &[T::Item]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

pub fn unfilled_init_part_mut(&mut self) -> &mut [T::Item]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Get the initialized part of the unfilled part, if there is any.

pub fn unfilled_uninit_part(&self) -> &[MaybeUninit<T::Item>]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Get the uninitialized part of the unfilled part, if there is any.

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

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

pub fn revert_to_start(&mut self)[src]

Revert the internal cursor to 0, forgetting about the initialized items.

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

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

pub fn advance_to_init_part(&mut self)[src]

pub unsafe fn assume_init(&mut self, count: usize)[src]

Increment the counter that marks the progress of filling, as well as the initialization progress, count items.

Safety

This does not initialize nor fill anything, and it is hence up to the user to ensure that no uninitialized items are marked initialized.

pub unsafe fn assume_init_all(&mut self)[src]

Mark the buffer as fully filled and initialized, without actually filling the buffer.

Safety

For this to be safe, the caller must ensure that every single item in the slice that the buffer wraps, is initialized.

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

impl<T> Buffer<T> where
    T: Initialize<Item = u8>, 
[src]

pub fn fill_by_zeroing(&mut self)[src]

impl<'a> Buffer<AsUninit<&'a mut [u8]>>[src]

pub fn from_slice_mut(slice: &'a mut [u8]) -> Self[src]

impl<'a> Buffer<&'a mut [MaybeUninit<u8>]>[src]

Trait Implementations

impl<T> Debug for Buffer<T> where
    T: Initialize
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Buffer<T> where
    T: RefUnwindSafe

impl<T> Send for Buffer<T> where
    T: Send

impl<T> Sync for Buffer<T> where
    T: Sync

impl<T> Unpin for Buffer<T> where
    T: Unpin

impl<T> UnwindSafe for Buffer<T> where
    T: UnwindSafe

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.