use std::fmt;
#[derive(Debug, thiserror::Error)]
pub enum RtspError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("invalid bind address: {0}")]
InvalidBindAddress(String),
#[error("session not found: {0}")]
SessionNotFound(String),
#[error("transport not configured for session: {0}")]
TransportNotConfigured(String),
#[error("session not in playing state: {0}")]
SessionNotPlaying(String),
#[error("server not started")]
NotStarted,
#[error("server already running")]
AlreadyRunning,
#[error("RTSP parse error: {kind}")]
Parse { kind: ParseErrorKind },
#[error("port range exhausted (tried to allocate beyond u16 range)")]
PortRangeExhausted,
#[error("mount not found: {0}")]
MountNotFound(String),
}
#[derive(Debug)]
pub enum ParseErrorKind {
EmptyRequest,
InvalidRequestLine,
InvalidHeader,
}
impl fmt::Display for ParseErrorKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::EmptyRequest => write!(f, "empty request"),
Self::InvalidRequestLine => write!(f, "invalid request line"),
Self::InvalidHeader => write!(f, "invalid header"),
}
}
}
pub type Result<T> = std::result::Result<T, RtspError>;