libfcp_core/error.rs
1// Copyright Nixort <https://github.com/Nixort> 2026.
2//
3// License: GNU General Public License v3.0 only.
4// You can find the license file in the project root.
5//
6// Federated CFR Connect Protocol (FCP).
7
8//! FCP parse, validation and state-machine errors.
9
10use core::fmt;
11
12/// FCP parse, validation and state-machine failure.
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub enum Error {
15 /// The envelope exceeded a fixed allocation bound.
16 TooLarge,
17 /// A variable field exceeded its kind-specific bound.
18 FieldTooLarge,
19 /// The envelope was truncated.
20 Truncated,
21 /// Bytes followed an otherwise complete envelope.
22 TrailingBytes,
23 /// Marker did not identify the FCP wire format.
24 BadMarker,
25 /// Version is not supported.
26 UnsupportedVersion,
27 /// Envelope kind is not known.
28 UnknownKind,
29 /// The endpoint public key did not parse strictly.
30 BadSenderKey,
31 /// The Ed25519 signature did not verify.
32 BadSignature,
33 /// Input was not the one canonical encoding of its parsed form.
34 NonCanonical,
35 /// Remote input did not bind to this federation.
36 WrongFederation,
37 /// Remote input did not bind to this attempt.
38 WrongAttempt,
39 /// Remote input was not authored by the configured peer endpoint.
40 WrongSender,
41 /// Remote input was not addressed to this local endpoint.
42 WrongRecipient,
43 /// The configured local and remote endpoint keys were identical.
44 SameEndpoint,
45 /// A local operation used a signer for another endpoint.
46 WrongLocalSigner,
47 /// Operation is not permitted in the current state.
48 InvalidState,
49 /// Both peers tried to offer while a local offer was outstanding.
50 Glare,
51 /// Candidate did not bind to an active offer or answer.
52 WrongCandidateParent,
53 /// Configuration marker did not identify the FCP configuration format.
54 BadConfigurationMarker,
55 /// Configuration version is not supported.
56 UnsupportedConfigurationVersion,
57 /// Configuration authority public key did not parse strictly.
58 BadConfigurationAuthority,
59 /// Configuration signer did not match the configuration's pinned authority.
60 WrongConfigurationAuthority,
61 /// Configuration signature did not verify.
62 BadConfigurationSignature,
63 /// Configuration declared more than the fixed member bound.
64 TooManyFederationMembers,
65 /// Configuration contains a duplicate CFR identity or endpoint binding.
66 DuplicateFederationMember,
67 /// ML-DSA-65 public-key bytes did not parse as canonical FCP identity material.
68 BadPostQuantumKey,
69 /// ML-DSA-65 signature encoding was not canonical.
70 BadPostQuantumSignatureEncoding,
71 /// ML-DSA-65 signature did not verify.
72 BadPostQuantumSignature,
73}
74
75impl fmt::Display for Error {
76 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
77 write!(formatter, "fcp error: {self:?}")
78 }
79}
80
81#[cfg(feature = "std")]
82impl std::error::Error for Error {}