cortexfs_channels/
error.rs1use std::time::Duration;
2
3#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
5pub enum ChannelError {
6 #[error("invalid channel value: {0}")]
7 InvalidValue(String),
8 #[error("invalid channel message: {0}")]
9 InvalidMessage(String),
10 #[error("channel already registered: {0}")]
11 DuplicateChannel(String),
12 #[error("unknown channel: {0}")]
13 UnknownChannel(String),
14 #[error("channel operation unsupported: {0}")]
15 Unsupported(String),
16 #[error("channel authentication failed")]
17 Authentication,
18 #[error("channel rate limited")]
19 RateLimited { retry: RetryHint },
20 #[error("channel transport failed: {0}")]
21 Transport(String),
22 #[error("channel protocol failed: {0}")]
23 Protocol(String),
24 #[error("channel is closed")]
25 Closed,
26}
27
28#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
30pub struct RetryHint(Option<Duration>);
31
32impl RetryHint {
33 #[must_use]
34 pub const fn none() -> Self {
35 Self(None)
36 }
37
38 #[must_use]
39 pub const fn after(delay: Duration) -> Self {
40 Self(Some(delay))
41 }
42
43 #[must_use]
44 pub const fn delay(self) -> Option<Duration> {
45 self.0
46 }
47}