Struct BuffersInitializer

Source
pub struct BuffersInitializer<T> { /* private fields */ }

Implementations§

Source§

impl<T> BuffersInitializer<T>

Source

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

Source

pub fn into_raw_parts(self) -> (T, usize, usize)

Source

pub fn into_inner(self) -> T

Source§

impl<T> BuffersInitializer<SingleVector<T>>

Source§

impl<T, Item> BuffersInitializer<T>
where T: InitializeVectored, T::UninitVector: Initialize<Item = Item>,

Source

pub fn current_vector_all(&self) -> Option<&[MaybeUninit<Item>]>

Retrieve the current buffer immutably, provided that there is one.

Source

pub unsafe fn current_vector_all_mut( &mut self, ) -> Option<&mut [MaybeUninit<Item>]>

Retrieve the current buffer mutably, provided that there is one.

§Safety

This is unsafe because the caller must not de-initialize the buffer.

Source

pub fn current_vector_init_part(&self) -> Option<&[Item]>

Source

pub fn current_vector_uninit_part(&self) -> Option<&[MaybeUninit<Item>]>

Source

pub fn current_vector_init_uninit_parts( &self, ) -> Option<(&[Item], &[MaybeUninit<Item>])>

Source

pub fn current_vector_init_part_mut(&mut self) -> Option<&mut [Item]>

Source

pub fn current_vector_uninit_part_mut( &mut self, ) -> Option<&mut [MaybeUninit<Item>]>

Source

pub fn current_vector_init_uninit_parts_mut( &mut self, ) -> Option<(&mut [Item], &mut [MaybeUninit<Item>])>

Source

pub fn total_vector_count(&self) -> usize

Get the total number of vectors, since the wrapper was constructed.

Source

pub fn vectors_initialized(&self) -> usize

Get the number of vectors that are currently filled and completely initialized.

Source

pub fn vectors_remaining(&self) -> usize

Get the number of vectors remaining, possibly including the vector that is currently initializing.

Source

pub fn count_items_to_initialize(&self) -> usize

Counts the items that must be filled before the whole buffer is initialized.

Note that this can be expensive if there are many buffers; it is O(n), where n is the number of vectors that have not yet been initialized. If all vectors are already filled, then this completes in constant time.

Source

pub fn count_total_items_in_all_vectors(&self) -> usize

Source

pub unsafe fn items_initialized_for_vector_unchecked( &self, vector_index: usize, ) -> usize

Get the number of items that have been initialized for the vector at the given index.

For vectors that has not yet been advanced to, this will zero, while vectors that are already initialized will return the full length of that vector. The currently initializing vector will return the partial length of the items within that vector that have been initialized.

§Safety

The caller must ensure that vector_index is within the bounds of the slice of vectors given by the inner wrapped value.

Source

pub fn items_initialized_for_vector(&self, vector_index: usize) -> usize

Source

pub fn items_initialized_for_current_vector(&self) -> usize

Source

pub fn all_uninit_vectors(&self) -> &[T::UninitVector]

Get the uninitialized version of all vectors wrapped by this initializer.

Source

pub unsafe fn all_uninit_vectors_mut(&mut self) -> &mut [T::UninitVector]

Get the uninitialized version of all vectors wrapped by this initializer, mutably.

§Safety

The caller must not de-initialize any values.

Source

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

Advance the initialization cursor by count items, counting the number of items that were advanced. The count input may be higher than the total number of items in the buffer, without panics or UB.

§Safety

For this to be safe, then count items in the vectors ranging from the current vector, to subsequent vectors, must be initialized.

Additionally, count must never overflow isize::MAX, but it may be larger than the total number of items in the vectors (to avoid having to count them in the beginning, for performance purposes).

Source

pub unsafe fn advance_current_vector_to_end(&mut self)

Advance the initialization progress to the end of the current vector, thus wrapping and continuing to the next

§Safety

This is unsafe not only because of the initialization invariant, but also because it does not check whether the initialized vectors counter is at the end (meaning that all vectors are initialized). The caller must hence ensure that the value of vectors_remaining is larger than zero.

Source

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

Source

pub fn partially_fill_current_vector_uninit_part( &mut self, count: usize, item: Item, )
where Item: Copy,

Source

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

Source

pub fn try_into_init(self) -> Result<AssertInitVectors<T>, Self>

Source§

impl<T> BuffersInitializer<T>

Auto Trait Implementations§

§

impl<T> Freeze for BuffersInitializer<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for BuffersInitializer<T>
where T: RefUnwindSafe,

§

impl<T> Send for BuffersInitializer<T>
where T: Send,

§

impl<T> Sync for BuffersInitializer<T>
where T: Sync,

§

impl<T> Unpin for BuffersInitializer<T>
where T: Unpin,

§

impl<T> UnwindSafe for BuffersInitializer<T>
where T: UnwindSafe,

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.