pub trait Allocator: Sync + Copy {
type Vec<T: Send>: VecLike<T> + Send;
// Required method
fn alloc<T: Send>(&self, capacity: usize) -> Self::Vec<T>;
}Expand description
A source of VecLike buffers.
Abstracts the allocation seam so callers can be generic over how their working buffers are
backed. The primary implementation is &BufferPool, whose Vec is
PoolVec — a buffer drawn from a recycling pool.
Sync is required because the prover shares &impl Allocator across rayon tasks (e.g. the
parallel fractional-addition GKR reduction); both &BufferPool and GlobalAllocator are
Sync.
Copy is required because a caller often hands the same allocator to several things at once
— a channel and the Merkle prover inside it, say. An allocator handle is a pool reference or a
unit struct, so both implementors are already Copy and the bound costs them nothing.
Required Associated Types§
Sourcetype Vec<T: Send>: VecLike<T> + Send
type Vec<T: Send>: VecLike<T> + Send
The buffer type this allocator hands out for element type T.
It is a VecLike buffer, and VecLike implies BufferData.
It grows and shrinks in place, so it can back a binius_math::FieldBuffer directly.
It is also Send so the prover can move pooled buffers across rayon tasks (e.g. the
parallel fractional-addition GKR reduction); every element type the prover pools is itself
Send.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".