offline_protocol_reliability/error.rs
1//! Reliability layer errors.
2
3use thiserror::Error;
4
5/// Result type alias.
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Reliability layer errors.
9// Adding a variant to a public error enum is a breaking change without
10// this attribute; downstream crates must carry a wildcard arm.
11#[non_exhaustive]
12#[derive(Debug, Error)]
13pub enum Error {
14 /// ACK timeout.
15 #[error("ACK timeout for message {0}")]
16 AckTimeout(String),
17
18 /// The pending-ACK table is full and nothing in it may be evicted for
19 /// this message.
20 ///
21 /// Typed rather than a string so a caller can tell "this frame cannot be
22 /// tracked right now" (defer it) from a genuine fault. A caller that
23 /// treats it as fatal after the frame has been transmitted reports a
24 /// failure for a message that is already on the wire.
25 #[error("Pending ACK table is full ({max} entries)")]
26 AckCapacity {
27 /// The configured ceiling.
28 max: usize,
29 },
30
31 /// Core error.
32 #[error("Core error: {0}")]
33 Core(#[from] offline_protocol_core::Error),
34
35 /// Generic error.
36 #[error("{0}")]
37 Other(String),
38}