base64_ng/v2/contracts/reporting.rs
1//! Stable reporting and destination-contract categories.
2
3/// Reporting category for the selected ordinary backend.
4#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
5#[non_exhaustive]
6pub enum BackendClass {
7 /// Portable scalar execution.
8 Scalar,
9 /// Admitted accelerated execution.
10 Accelerated,
11 /// Redundantly checked backend execution.
12 Checked,
13}
14
15impl BackendClass {
16 /// Returns the stable lowercase reporting identifier.
17 #[must_use]
18 pub const fn as_str(self) -> &'static str {
19 match self {
20 Self::Scalar => "scalar",
21 Self::Accelerated => "accelerated",
22 Self::Checked => "checked",
23 }
24 }
25}
26
27/// Reporting category for an operation's assurance boundary.
28#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
29#[non_exhaustive]
30pub enum AssuranceClass {
31 /// Ordinary input-dependent operation.
32 Ordinary,
33 /// Ordinary operation with redundant backend checking.
34 CheckedBackend,
35 /// Constant-time-oriented bounded secret operation.
36 Secret,
37 /// Deployment-attested high-assurance operation.
38 HighAssurance,
39}
40
41impl AssuranceClass {
42 /// Returns the stable lowercase reporting identifier.
43 #[must_use]
44 pub const fn as_str(self) -> &'static str {
45 match self {
46 Self::Ordinary => "ordinary",
47 Self::CheckedBackend => "checked-backend",
48 Self::Secret => "secret",
49 Self::HighAssurance => "high-assurance",
50 }
51 }
52}
53
54/// Reporting scope for core and companion protocol behavior.
55#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
56#[non_exhaustive]
57pub enum ProtocolScope {
58 /// RFC 4648 core codec behavior.
59 Core,
60 /// Explicit compatibility behavior that is not strict RFC 4648.
61 Compatibility,
62 /// A separately named companion protocol.
63 Companion,
64}
65
66impl ProtocolScope {
67 /// Returns the stable lowercase reporting identifier.
68 #[must_use]
69 pub const fn as_str(self) -> &'static str {
70 match self {
71 Self::Core => "core",
72 Self::Compatibility => "compatibility",
73 Self::Companion => "companion",
74 }
75 }
76}
77
78/// Destination mutation contract used by API and corpus metadata.
79#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
80#[non_exhaustive]
81pub enum Atomicity {
82 /// Destination bytes remain unchanged on every returned error.
83 Unchanged,
84 /// A rewindable destination is restored to its entry length or position.
85 Rollback,
86 /// Exact reported prefixes remain committed.
87 CommittedPrefix,
88 /// A third-party sink may have irreversible or unknowable side effects.
89 IrrevocableSink,
90}
91
92impl Atomicity {
93 /// Returns the stable lowercase corpus/reporting identifier.
94 #[must_use]
95 pub const fn as_str(self) -> &'static str {
96 match self {
97 Self::Unchanged => "unchanged",
98 Self::Rollback => "rollback",
99 Self::CommittedPrefix => "committed-prefix",
100 Self::IrrevocableSink => "irrevocable-sink",
101 }
102 }
103}