ozzy_replication/wire/
error.rs1use ozzy_proto::EnvelopeError;
4use ozzy_proto::layout::LayoutError;
5
6use crate::ReplicationError;
7use crate::flow::FlowError;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
11pub enum WireError {
12 #[error(transparent)]
14 Flow(#[from] FlowError),
15 #[error("replica history response does not match the outstanding request")]
17 Transfer,
18 #[error("invalid replica election history descriptor")]
20 History,
21 #[error("replica command exceeds operation or byte limits")]
23 Limit,
24 #[error("unsupported replica operation kind {0}")]
26 OperationKind(u16),
27 #[error("replica canonical operation chain mismatch")]
29 Chain,
30 #[error("replica canonical operation digest mismatch")]
32 Digest,
33 #[error(transparent)]
35 Envelope(#[from] EnvelopeError),
36 #[error(transparent)]
38 Configuration(#[from] ReplicationError),
39 #[error("replica peer or session mismatch")]
41 Peer,
42 #[error("replica configuration scope mismatch")]
44 Scope,
45 #[error("invalid replica log prefix")]
47 Prefix,
48 #[error("unexpected replica payload")]
50 Payload,
51 #[error("replica metadata length mismatch")]
53 Length,
54 #[error("replica encoding buffer too small")]
56 Capacity,
57 #[error("invalid replica command correlation")]
59 Correlation,
60 #[error("unsupported replica command")]
62 UnsupportedCommand,
63}
64
65impl From<LayoutError> for WireError {
66 fn from(error: LayoutError) -> Self {
67 match error {
68 LayoutError::Truncated { .. } | LayoutError::Trailing(_) => Self::Length,
69 LayoutError::Overflow { .. } => Self::Capacity,
70 }
71 }
72}