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>
impl<'vec, T> VecWriter<'vec, T>
Sourcepub fn new(storage: &'vec mut Vec<T>) -> Self
pub fn new(storage: &'vec mut Vec<T>) -> Self
Creates a new writer that will write into the supplied Vec.
Sourcepub fn take_shard(&mut self, n: usize) -> Shard<'vec, T>
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.
Sourcepub fn try_take_shard(
&mut self,
n: usize,
) -> Result<Shard<'vec, T>, InsufficientCapacity>
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.
Sourcepub fn take_shards(
&mut self,
sizes: impl Iterator<Item = usize>,
) -> Vec<Shard<'vec, T>>
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.
pub fn try_take_shards( &mut self, sizes: impl Iterator<Item = usize>, ) -> Result<Vec<Shard<'vec, T>>, InsufficientCapacity>
Sourcepub fn return_shard(&mut self, shard: Shard<'_, T>)
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.
Sourcepub fn try_return_shard(&mut self, shard: Shard<'_, T>) -> Result<(), InitError>
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.
Sourcepub fn return_shards(&mut self, shards: Vec<Shard<'_, T>>)
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.