Skip to main content

core_utils/preprocessing/
batching.rs

1use std::ops::{Add, Mul};
2
3use primitives::types::{Batched, Positive, PositivePlusOne};
4use typenum::{Prod, B1, U2, U3, U4, U5, U6};
5
6use crate::preprocessing::Preprocessing;
7
8/// A marker trait for batched preprocessing types that are composed of
9/// individual items of preprocessing types.
10pub trait BatchedPreprocessing: Preprocessing + Batched<Item: Preprocessing> {}
11impl<T: Preprocessing + Batched<Item: Preprocessing>> BatchedPreprocessing for T {}
12
13/// A generic trait to serve as batch size across all protocols. To be replaced
14/// by const generics if they ever stabilize.
15pub trait BatchSize:
16    Positive
17    + Add<B1, Output: Positive + Add<B1, Output: Positive>>
18    + Mul<U2, Output: Positive + Mul<U3, Output = Prod<Self, U6>>>
19    + Mul<U3, Output: Positive + Mul<U2, Output = Prod<Self, U6>>>
20    + Mul<U4, Output: Positive>
21    + Mul<U5, Output: Positive>
22    + Mul<U6, Output: Positive + Add<B1, Output: Positive>>
23{
24}
25impl<
26        T: Positive
27            + Add<B1, Output: PositivePlusOne>
28            + Mul<U2, Output: Positive + Mul<U3, Output = Prod<T, U6>>>
29            + Mul<U3, Output: Positive + Mul<U2, Output = Prod<T, U6>>>
30            + Mul<U4, Output: Positive>
31            + Mul<U5, Output: Positive>
32            + Mul<U6, Output: PositivePlusOne>,
33    > BatchSize for T
34{
35}