Skip to main content

cesr/core/matter/
mod.rs

1use core::fmt::Display;
2
3/// Builder for constructing and parsing `Matter` primitives.
4pub mod builder;
5/// CESR code enums (`MatterCode`, `SeedCode`, `VerKeyCode`, `SignatureCode`, `DigestCode`, etc.).
6pub mod code;
7/// Parse and build error types for Matter streams.
8pub mod error;
9/// `Matter<C>` generic CESR primitive type.
10#[allow(
11    clippy::module_inception,
12    reason = "Matter module contains the Matter type"
13)]
14pub mod matter;
15
16pub use matter::Matter;
17/// Sizing table (`Sizage`) for Matter codes.
18pub mod sizage;
19
20#[cfg(test)]
21mod test_vectors;
22#[cfg(test)]
23mod test_vectors_boundary;
24
25/// Identifies which structural component of a CESR Matter field was involved in an error.
26#[derive(Debug, Copy, Clone, PartialEq, Eq)]
27pub enum MatterPart {
28    /// The fixed-length code header (hard + soft fields).
29    Head,
30    /// The soft (variable) portion of the code field.
31    Soft,
32    /// The extra field used by certain multi-field codes.
33    Xtra,
34    /// Padding bits prepended to align binary data to a sextet boundary.
35    PadBits,
36    /// Lead bytes used for alignment in binary (qb2) encoding.
37    LeadBytes,
38    /// Raw payload bytes carrying the primitive's value.
39    Raw,
40}
41
42impl Display for MatterPart {
43    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
44        write!(f, "{self:?}")
45    }
46}