1use crate::layouts::{Backend, MatZnx, ScalarZnx, VecZnx};
2
3pub trait ModuleNew<B: Backend> {
5 type Config: Default = ();
8
9 fn new(n: u64) -> Self;
10
11 fn new_with(n: u64, config: Self::Config) -> Self;
13}
14
15pub trait ModuleN {
17 fn n(&self) -> usize;
18}
19
20pub trait ModuleLogN
22where
23 Self: ModuleN,
24{
25 fn log_n(&self) -> usize {
26 (u64::BITS - (self.n() as u64 - 1).leading_zeros()) as usize
27 }
28}
29
30pub trait ScalarZnxAlloc<B: Backend>: ModuleN {
32 fn scalar_znx_alloc(&self, cols: usize) -> ScalarZnx<B::OwnedBuf, B::ZnxWord>;
33}
34
35pub trait VecZnxAlloc<B: Backend>: ModuleN {
37 fn vec_znx_alloc(&self, cols: usize, size: usize) -> VecZnx<B::OwnedBuf, B::ZnxWord>;
38}
39
40pub trait MatZnxAlloc<B: Backend>: ModuleN {
42 fn mat_znx_alloc(&self, rows: usize, cols_in: usize, cols_out: usize, size: usize) -> MatZnx<B::OwnedBuf, B::ZnxWord>;
43}