1use crate::{Alphabet, Profile, ct};
2
3pub struct Engine<A, const PAD: bool> {
5 alphabet: core::marker::PhantomData<A>,
6}
7
8impl<A, const PAD: bool> Clone for Engine<A, PAD> {
9 fn clone(&self) -> Self {
10 *self
11 }
12}
13
14impl<A, const PAD: bool> Copy for Engine<A, PAD> {}
15
16impl<A, const PAD: bool> core::fmt::Debug for Engine<A, PAD> {
17 fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
18 formatter
19 .debug_struct("Engine")
20 .field("padded", &PAD)
21 .finish()
22 }
23}
24
25impl<A, const PAD: bool> core::fmt::Display for Engine<A, PAD> {
26 fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
27 write!(formatter, "padded={PAD}")
28 }
29}
30
31impl<A, const PAD: bool> Default for Engine<A, PAD> {
32 fn default() -> Self {
33 Self {
34 alphabet: core::marker::PhantomData,
35 }
36 }
37}
38
39impl<A, const PAD: bool> Eq for Engine<A, PAD> {}
40
41impl<A, const PAD: bool> PartialEq for Engine<A, PAD> {
42 fn eq(&self, _other: &Self) -> bool {
43 true
44 }
45}
46
47impl<A, const PAD: bool> Engine<A, PAD>
48where
49 A: Alphabet,
50{
51 #[must_use]
53 pub const fn new() -> Self {
54 Self {
55 alphabet: core::marker::PhantomData,
56 }
57 }
58
59 #[must_use]
61 pub const fn is_padded(&self) -> bool {
62 PAD
63 }
64
65 #[must_use]
70 pub const fn profile(&self) -> Profile<A, PAD> {
71 Profile::new(*self, None)
72 }
73
74 #[must_use]
80 pub const fn ct_decoder(&self) -> ct::CtEngine<A, PAD> {
81 ct::CtEngine::new()
82 }
83}
84
85mod decode;
86mod decode_in_place;
87mod encode;
88mod encode_in_place;
89mod stream;
90mod validate;