pub struct ScratchArena<'a, B>where
B: Backend,{ /* private fields */ }Expand description
Backend-native scratch arena borrowed from a ScratchOwned.
This arena keeps backend ownership explicit and carves typed temporaries
using the backend’s native borrowed buffer view (B::BufMut<'a>).
Implementations§
Source§impl<'a, B> ScratchArena<'a, B>where
B: Backend,
impl<'a, B> ScratchArena<'a, B>where
B: Backend,
Sourcepub fn borrow<'b>(&'b mut self) -> ScratchArena<'b, B>
pub fn borrow<'b>(&'b mut self) -> ScratchArena<'b, B>
Reborrows this arena with a shorter lifetime.
Sourcepub fn scope<R>(
&mut self,
f: impl for<'b> FnOnce(ScratchArena<'b, B>) -> R,
) -> R
pub fn scope<R>( &mut self, f: impl for<'b> FnOnce(ScratchArena<'b, B>) -> R, ) -> R
Runs f with a shorter-lived reborrow of this arena.
This is useful for nested workspace use where the borrowed arena must not leak into the outer function’s scratch lifetime.
Sourcepub fn apply_mut(
self,
f: impl FnOnce(&mut ScratchArena<'a, B>),
) -> ScratchArena<'a, B>
pub fn apply_mut( self, f: impl FnOnce(&mut ScratchArena<'a, B>), ) -> ScratchArena<'a, B>
Applies f to this arena through a temporary mutable borrow and returns the advanced arena.
This is useful while migrating callers that still thread scratch by value around newer
&mut ScratchArena APIs.
Sourcepub fn consume<R>(
&mut self,
f: impl for<'b> FnOnce(ScratchArena<'b, B>) -> (R, ScratchArena<'b, B>),
) -> R
pub fn consume<R>( &mut self, f: impl for<'b> FnOnce(ScratchArena<'b, B>) -> (R, ScratchArena<'b, B>), ) -> R
Runs f on a shorter-lived owned reborrow and commits the returned remainder.
This is useful while migrating APIs from arena-by-value to &mut ScratchArena:
existing helpers can keep their (result, remainder) style internally, while the
outer mutable arena advances to the returned remainder.
Sourcepub fn available(&self) -> usize
pub fn available(&self) -> usize
Returns the number of aligned bytes that can still be carved out.
Sourcepub fn split_at(self, len: usize) -> (ScratchArena<'a, B>, ScratchArena<'a, B>)
pub fn split_at(self, len: usize) -> (ScratchArena<'a, B>, ScratchArena<'a, B>)
Splits off len aligned bytes from the front of this arena.
Sourcepub fn split(
self,
n: usize,
len: usize,
) -> (Vec<ScratchArena<'a, B>>, ScratchArena<'a, B>)
pub fn split( self, n: usize, len: usize, ) -> (Vec<ScratchArena<'a, B>>, ScratchArena<'a, B>)
Splits this arena into n disjoint aligned chunks of len bytes each.
Sourcepub fn take_region(
self,
len: usize,
) -> (<B as Backend>::BufMut<'a>, ScratchArena<'a, B>)
pub fn take_region( self, len: usize, ) -> (<B as Backend>::BufMut<'a>, ScratchArena<'a, B>)
Takes a backend-native mutable region of len bytes.
Trait Implementations§
Source§impl<'a, B> ScratchArenaTakeBasic<'a, B> for ScratchArena<'a, B>where
B: Backend,
impl<'a, B> ScratchArenaTakeBasic<'a, B> for ScratchArena<'a, B>where
B: Backend,
Source§fn take_cnv_pvec_left_scratch<M>(
self,
module: &M,
cols: usize,
size: usize,
) -> (CnvPVecLViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: ModuleN + CnvPVecBytesOf,
fn take_cnv_pvec_left_scratch<M>(
self,
module: &M,
cols: usize,
size: usize,
) -> (CnvPVecLViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: ModuleN + CnvPVecBytesOf,
CnvPVecL from the scratch arena.Source§fn take_cnv_pvec_right_scratch<M>(
self,
module: &M,
cols: usize,
size: usize,
) -> (CnvPVecRViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: ModuleN + CnvPVecBytesOf,
fn take_cnv_pvec_right_scratch<M>(
self,
module: &M,
cols: usize,
size: usize,
) -> (CnvPVecRViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: ModuleN + CnvPVecBytesOf,
CnvPVecR from the scratch arena.Source§fn take_scalar_znx_scratch(
self,
n: usize,
cols: usize,
) -> (ScalarZnxViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
fn take_scalar_znx_scratch(
self,
n: usize,
cols: usize,
) -> (ScalarZnxViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
ScalarZnx from the scratch arena.Source§fn take_svp_ppol_scratch<M>(
self,
module: &M,
cols: usize,
) -> (SvpPPolViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: SvpPPolBytesOf + ModuleN,
fn take_svp_ppol_scratch<M>(
self,
module: &M,
cols: usize,
) -> (SvpPPolViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: SvpPPolBytesOf + ModuleN,
SvpPPol from the scratch arena.Source§fn take_vec_znx_scratch(
self,
n: usize,
cols: usize,
size: usize,
) -> (VecZnxViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
fn take_vec_znx_scratch(
self,
n: usize,
cols: usize,
size: usize,
) -> (VecZnxViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
VecZnx from the scratch arena.Source§fn take_vec_znx_big_scratch<M>(
self,
module: &M,
cols: usize,
size: usize,
) -> (VecZnxBigViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: VecZnxBigBytesOf + ModuleN,
fn take_vec_znx_big_scratch<M>(
self,
module: &M,
cols: usize,
size: usize,
) -> (VecZnxBigViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: VecZnxBigBytesOf + ModuleN,
VecZnxBig from the scratch arena.fn take_vec_znx_big_scratch_n(
self,
n: usize,
cols: usize,
size: usize,
) -> (VecZnxBigViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
Source§fn take_vec_znx_dft_scratch<M>(
self,
module: &M,
cols: usize,
size: usize,
) -> (VecZnxDftViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: VecZnxDftBytesOf + ModuleN,
fn take_vec_znx_dft_scratch<M>(
self,
module: &M,
cols: usize,
size: usize,
) -> (VecZnxDftViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: VecZnxDftBytesOf + ModuleN,
VecZnxDft from the scratch arena.Source§fn take_vmp_pmat_scratch<M>(
self,
module: &M,
rows: usize,
cols_in: usize,
cols_out: usize,
size: usize,
) -> (VmpPMatViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: VmpPMatBytesOf + ModuleN,
fn take_vmp_pmat_scratch<M>(
self,
module: &M,
rows: usize,
cols_in: usize,
cols_out: usize,
size: usize,
) -> (VmpPMatViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
M: VmpPMatBytesOf + ModuleN,
VmpPMat from the scratch arena.Source§fn take_mat_znx_scratch(
self,
n: usize,
rows: usize,
cols_in: usize,
cols_out: usize,
size: usize,
) -> (MatZnxViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
fn take_mat_znx_scratch(
self,
n: usize,
rows: usize,
cols_in: usize,
cols_out: usize,
size: usize,
) -> (MatZnxViewMut<'a, B>, ScratchArena<'a, B>)where
B: 'a,
MatZnx from the scratch arena.Source§fn take_vec_znx_dft_slice_scratch<M>(
self,
module: &M,
len: usize,
cols: usize,
size: usize,
) -> (Vec<VecZnxDftViewMut<'a, B>>, Self)where
B: 'a,
M: VecZnxDftBytesOf + ModuleN,
fn take_vec_znx_dft_slice_scratch<M>(
self,
module: &M,
len: usize,
cols: usize,
size: usize,
) -> (Vec<VecZnxDftViewMut<'a, B>>, Self)where
B: 'a,
M: VecZnxDftBytesOf + ModuleN,
len consecutive VecZnxDft objects from the scratch arena.Source§fn take_vec_znx_slice_scratch(
self,
len: usize,
n: usize,
cols: usize,
size: usize,
) -> (Vec<VecZnxViewMut<'a, B>>, Self)where
B: 'a,
fn take_vec_znx_slice_scratch(
self,
len: usize,
n: usize,
cols: usize,
size: usize,
) -> (Vec<VecZnxViewMut<'a, B>>, Self)where
B: 'a,
len consecutive VecZnx objects from the scratch arena.Source§impl<'a, B> ScratchArenaTakeCore<'a, B> for ScratchArena<'a, B>where
B: Backend,
impl<'a, B> ScratchArenaTakeCore<'a, B> for ScratchArena<'a, B>where
B: Backend,
Source§fn take_lwe_scratch<A>(self, infos: &A) -> (LWEViewMut<'a, B>, Self)where
B: 'a,
A: LWEInfos,
fn take_lwe_scratch<A>(self, infos: &A) -> (LWEViewMut<'a, B>, Self)where
B: 'a,
A: LWEInfos,
LWE ciphertext from scratch space.Source§fn take_lwe_plaintext_scratch<A>(
self,
infos: &A,
) -> (LWEPlaintextViewMut<'a, B>, Self)where
B: 'a,
A: LWEInfos,
fn take_lwe_plaintext_scratch<A>(
self,
infos: &A,
) -> (LWEPlaintextViewMut<'a, B>, Self)where
B: 'a,
A: LWEInfos,
LWEPlaintext from scratch space.Source§fn take_glwe_scratch<A>(self, infos: &A) -> (GLWEViewMut<'a, B>, Self)where
B: 'a,
A: GLWEInfos,
fn take_glwe_scratch<A>(self, infos: &A) -> (GLWEViewMut<'a, B>, Self)where
B: 'a,
A: GLWEInfos,
GLWE ciphertext from scratch space.Source§fn take_glwe_slice_scratch<A>(
self,
size: usize,
infos: &A,
) -> (Vec<GLWEViewMut<'a, B>>, Self)where
B: 'a,
A: GLWEInfos,
fn take_glwe_slice_scratch<A>(
self,
size: usize,
infos: &A,
) -> (Vec<GLWEViewMut<'a, B>>, Self)where
B: 'a,
A: GLWEInfos,
Source§fn take_glwe_tensor_scratch<A>(
self,
infos: &A,
) -> (GLWETensorViewMut<'a, B>, Self)where
B: 'a,
A: GLWEInfos,
fn take_glwe_tensor_scratch<A>(
self,
infos: &A,
) -> (GLWETensorViewMut<'a, B>, Self)where
B: 'a,
A: GLWEInfos,
GLWETensor from scratch space.Source§fn take_glwe_plaintext_scratch<A>(
self,
infos: &A,
) -> (GLWEPlaintextViewMut<'a, B>, Self)where
B: 'a,
A: GLWEInfos,
fn take_glwe_plaintext_scratch<A>(
self,
infos: &A,
) -> (GLWEPlaintextViewMut<'a, B>, Self)where
B: 'a,
A: GLWEInfos,
GLWEPlaintext from scratch space.Source§fn take_glwe_secret_prepared_scratch<M>(
self,
module: &M,
rank: Rank,
) -> (GLWESecretPreparedViewMut<'a, B>, Self)where
B: 'a,
M: ModuleN + SvpPPolBytesOf,
fn take_glwe_secret_prepared_scratch<M>(
self,
module: &M,
rank: Rank,
) -> (GLWESecretPreparedViewMut<'a, B>, Self)where
B: 'a,
M: ModuleN + SvpPPolBytesOf,
GLWESecretPrepared (DFT-domain secret key) from scratch space.Source§fn take_glwe_secret_scratch(
self,
n: Degree,
rank: Rank,
) -> (GLWESecretViewMut<'a, B>, Self)where
B: 'a,
fn take_glwe_secret_scratch(
self,
n: Degree,
rank: Rank,
) -> (GLWESecretViewMut<'a, B>, Self)where
B: 'a,
GLWESecret from scratch space.Source§fn take_glwe_secret_tensor_scratch(
self,
n: Degree,
rank: Rank,
) -> (GLWESecretTensorViewMut<'a, B>, Self)where
B: 'a,
fn take_glwe_secret_tensor_scratch(
self,
n: Degree,
rank: Rank,
) -> (GLWESecretTensorViewMut<'a, B>, Self)where
B: 'a,
GLWESecretTensor from scratch space.Source§fn take_gglwe_scratch<A>(self, infos: &A) -> (GGLWEViewMut<'a, B>, Self)where
B: 'a,
A: GGLWEInfos,
fn take_gglwe_scratch<A>(self, infos: &A) -> (GGLWEViewMut<'a, B>, Self)where
B: 'a,
A: GGLWEInfos,
GGLWE ciphertext from scratch space.Source§fn take_gglwe_prepared_scratch<A, M>(
self,
module: &M,
infos: &A,
) -> (GGLWEPreparedViewMut<'a, B>, Self)
fn take_gglwe_prepared_scratch<A, M>( self, module: &M, infos: &A, ) -> (GGLWEPreparedViewMut<'a, B>, Self)
GGLWEPrepared (DFT-domain GGLWE) from scratch space.Source§fn take_ggsw_scratch<A>(self, infos: &A) -> (GGSWViewMut<'a, B>, Self)where
B: 'a,
A: GGSWInfos,
fn take_ggsw_scratch<A>(self, infos: &A) -> (GGSWViewMut<'a, B>, Self)where
B: 'a,
A: GGSWInfos,
GGSW ciphertext from scratch space.Source§fn take_ggsw_prepared_scratch<A, M>(
self,
module: &M,
infos: &A,
) -> (GGSWPreparedViewMut<'a, B>, Self)
fn take_ggsw_prepared_scratch<A, M>( self, module: &M, infos: &A, ) -> (GGSWPreparedViewMut<'a, B>, Self)
GGSWPrepared (DFT-domain GGSW) from scratch space.Source§impl<B> ScratchAvailable for ScratchArena<'_, B>where
B: Backend,
impl<B> ScratchAvailable for ScratchArena<'_, B>where
B: Backend,
Auto Trait Implementations§
impl<'a, B> Freeze for ScratchArena<'a, B>
impl<'a, B> RefUnwindSafe for ScratchArena<'a, B>
impl<'a, B> !Send for ScratchArena<'a, B>
impl<'a, B> !Sync for ScratchArena<'a, B>
impl<'a, B> Unpin for ScratchArena<'a, B>
impl<'a, B> UnsafeUnpin for ScratchArena<'a, B>
impl<'a, B> !UnwindSafe for ScratchArena<'a, B>
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> 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