#[non_exhaustive]pub enum ScratchRequirement {
None,
Fixed {
bytes: usize,
},
PerElement {
bytes_per_element: usize,
},
Unbounded,
}Expand description
Scratch memory an operation needs beyond its inputs and outputs.
Declared up front so a caller can budget, pre-reserve, or refuse before any
work starts. Unbounded is deliberately representable and deliberately
unpleasant: an operation that cannot bound its scratch must say so rather
than allocating silently in a hot loop.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
None
Operates in place; no scratch beyond inputs and outputs.
Fixed
At most bytes of scratch, independent of input size.
PerElement
At most bytes_per_element * elements of scratch.
Unbounded
Scratch cannot be bounded ahead of time.
Callers must treat this as “may allocate arbitrarily”; a memory budget cannot be enforced against it.
Implementations§
Source§impl ScratchRequirement
impl ScratchRequirement
Sourcepub const fn upper_bound_bytes(self, elements: usize) -> Option<usize>
pub const fn upper_bound_bytes(self, elements: usize) -> Option<usize>
Upper bound for elements inputs, or None when unbounded.
Sourcepub fn fits_budget(self, options: &ExecutionOptions, elements: usize) -> bool
pub fn fits_budget(self, options: &ExecutionOptions, elements: usize) -> bool
Whether this requirement fits options’ memory budget for elements.
An unbounded requirement never fits a declared budget: allowing it would make the budget advisory, which is the failure this type exists to stop. Whether this requirement fits the caller’s memory budget.
No longer const: it reads an ExecutionOptions that now owns a
shared cancellation handle, so it cannot be destructured at compile
time. Budget checks happen once per dispatch, not on a hot path.
Trait Implementations§
Source§impl Clone for ScratchRequirement
impl Clone for ScratchRequirement
Source§fn clone(&self) -> ScratchRequirement
fn clone(&self) -> ScratchRequirement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScratchRequirement
impl Debug for ScratchRequirement
Source§impl Hash for ScratchRequirement
impl Hash for ScratchRequirement
Source§impl PartialEq for ScratchRequirement
impl PartialEq for ScratchRequirement
impl Copy for ScratchRequirement
impl Eq for ScratchRequirement
impl StructuralPartialEq for ScratchRequirement
Auto Trait Implementations§
impl Freeze for ScratchRequirement
impl RefUnwindSafe for ScratchRequirement
impl Send for ScratchRequirement
impl Sync for ScratchRequirement
impl Unpin for ScratchRequirement
impl UnwindSafe for ScratchRequirement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more