use thiserror::Error;
#[derive(Debug, Error)]
pub enum ShairplayError {
#[error("server error: {0}")]
Server(#[from] ServerError),
#[error("crypto error: {0}")]
Crypto(#[from] CryptoError),
#[error("network error: {0}")]
Network(#[from] NetworkError),
#[error("protocol error: {0}")]
Protocol(#[from] ProtocolError),
#[error("codec error: {0}")]
Codec(#[from] CodecError),
}
#[derive(Debug, Error)]
pub enum ServerError {
#[error("server not started")]
NotStarted,
#[error("server already running")]
AlreadyRunning,
#[error("max clients reached ({0})")]
MaxClients(usize),
#[error("invalid hardware address length: {0}")]
InvalidHwAddr(usize),
#[error("invalid password length: {0}")]
InvalidPassword(usize),
#[error("audio handler error: {0}")]
AudioHandler(String),
}
#[derive(Debug, Error)]
pub enum CryptoError {
#[error("RSA key error: {0}")]
RsaKey(String),
#[error("RSA decryption failed")]
RsaDecrypt,
#[error("pairing handshake failed: {0}")]
PairingHandshake(String),
#[error("pairing verification failed")]
PairingVerify,
#[error("FairPlay handshake failed: {0}")]
FairPlay(String),
#[error("AES error: {0}")]
Aes(String),
}
#[derive(Debug, Error)]
pub enum NetworkError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("mDNS registration failed: {0}")]
Mdns(String),
#[error("bind failed on port {0}")]
Bind(u16),
}
#[derive(Debug, Error)]
pub enum ProtocolError {
#[error("invalid RTSP request: {0}")]
InvalidRtsp(String),
#[error("SDP parse error: {0}")]
Sdp(String),
#[error("plist parse error: {0}")]
Plist(String),
#[error("HTTP digest auth error: {0}")]
DigestAuth(String),
#[error("incomplete request")]
Incomplete,
}
#[derive(Debug, Error)]
pub enum CodecError {
#[error("ALAC decode error: {0}")]
AlacDecode(String),
#[error("AAC decode error: {0}")]
AacDecode(String),
#[error("unsupported format: {0}")]
UnsupportedFormat(String),
}