Skip to main content

oaat_core/
error.rs

1use crate::session::SessionState;
2
3#[derive(Debug, thiserror::Error)]
4pub enum OaatError {
5    #[error("unknown audio format wire ID: 0x{0:02x}")]
6    UnknownFormat(u8),
7
8    #[error("invalid packet flags: 0x{0:02x}")]
9    InvalidPacketFlags(u8),
10
11    #[error("invalid clock sync type: 0x{0:02x}")]
12    InvalidClockSyncType(u8),
13
14    #[error("invalid state transition: {from} -> {to}")]
15    InvalidStateTransition {
16        from: SessionState,
17        to: SessionState,
18    },
19
20    #[error("invalid capability string: {0:?}")]
21    InvalidCapabilityString(String),
22
23    #[error("protocol version mismatch: expected {expected}, got {got}")]
24    VersionMismatch { expected: u32, got: u32 },
25
26    #[error("message too large: {0} bytes")]
27    MessageTooLarge(usize),
28
29    #[error("incomplete frame: need {need} bytes, have {have}")]
30    IncompleteFrame { need: usize, have: usize },
31
32    #[error("io: {0}")]
33    Io(#[from] std::io::Error),
34
35    #[error("json: {0}")]
36    Json(#[from] serde_json::Error),
37
38    #[error("protocol: {0}")]
39    Protocol(String),
40}