Skip to main content

VecWriter

Struct VecWriter 

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

Builds a Vec<T>, with each variable-sized chunk of the Vec being initialised separately, most likely from a separate thread.

Implementations§

Source§

impl<'vec, T> VecWriter<'vec, T>

Source

pub fn new(storage: &'vec mut Vec<T>) -> Self

Creates a new writer that will write into the supplied Vec.

Source

pub fn take_shard(&mut self, n: usize) -> Shard<'vec, T>

Takes the next n elements of the vector or panics if there is insufficient capacity.

Source

pub fn try_take_shard( &mut self, n: usize, ) -> Result<Shard<'vec, T>, InsufficientCapacity>

Takes the next n elements of the vector or returns an error if there is insufficient capacity.

Source

pub fn take_shards( &mut self, sizes: impl Iterator<Item = usize>, ) -> Vec<Shard<'vec, T>>

Takes shards with sizes supplied by sizes. Panics if there is insufficient capacity.

Source

pub fn try_take_shards( &mut self, sizes: impl Iterator<Item = usize>, ) -> Result<Vec<Shard<'vec, T>>, InsufficientCapacity>

Source

pub fn return_shard(&mut self, shard: Shard<'_, T>)

Returns a shard to the vector, increasing the initialised length of the vector by the size of the shard. The shard must have been fully initialised before being returned. Shards must be returned in order. Panics on failure.

Source

pub fn try_return_shard(&mut self, shard: Shard<'_, T>) -> Result<(), InitError>

As for return_shard, but returns an error on failure rather than panicking.

Source

pub fn return_shards(&mut self, shards: Vec<Shard<'_, T>>)

Returns the supplied shards. Panics if any shards have not been fully initialised or if the shards are out-of-order.

Source

pub fn try_return_shards( &mut self, shards: Vec<Shard<'_, T>>, ) -> Result<(), InitError>

Returns the supplied shards.

Auto Trait Implementations§

§

impl<'vec, T> Freeze for VecWriter<'vec, T>

§

impl<'vec, T> RefUnwindSafe for VecWriter<'vec, T>
where T: RefUnwindSafe,

§

impl<'vec, T> Send for VecWriter<'vec, T>
where T: Send,

§

impl<'vec, T> Sync for VecWriter<'vec, T>
where T: Sync,

§

impl<'vec, T> Unpin for VecWriter<'vec, T>

§

impl<'vec, T> UnsafeUnpin for VecWriter<'vec, T>

§

impl<'vec, T> !UnwindSafe for VecWriter<'vec, 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.