Skip to main content

BufferData

Trait BufferData 

Source
pub trait BufferData<T>: DerefMut<Target = [T]> {
    // Required method
    fn truncate(&mut self, len: usize);
}
Expand description

Backing store of a binius_math::FieldBuffer that can be shrunk in place.

This lives here, rather than in binius-math, so that it can be a bound on Allocator::Vec — that bound is what lets generic allocation code back a FieldBuffer with an allocator’s buffer A::Vec<P> without threading a where A::Vec<P>: BufferData<P> clause through every signature. FieldBuffer::truncate shrinks its backing store to match a smaller log_len, so it is available only for the mutable backings that support that in place.

This trait is the shrinkable-store capability alone, and VecLike is that plus growth. Three backings implement it:

  • Vec<T> and PoolVec both shrink and grow, so both are VecLike as well.
  • &mut [T] only shrinks, by re-slicing, which is what slice-backed sumcheck halves need.

Required Methods§

Source

fn truncate(&mut self, len: usize)

Shrinks the store in place to its first len elements.

len must be at most the current length.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> BufferData<T> for &mut [T]

Source§

fn truncate(&mut self, len: usize)

Source§

impl<T> BufferData<T> for Vec<T>

Source§

fn truncate(&mut self, len: usize)

Implementors§

Source§

impl<T> BufferData<T> for PoolVec<'_, T>