use crate::Method;
use crate::state::SessionState;
pub type Result<T> = core::result::Result<T, Error>;
#[non_exhaustive]
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
pub enum Error {
#[error("failed to parse RTSP message: {0}")]
MessageParse(String),
#[error("failed to serialize RTSP message: {0}")]
MessageWrite(String),
#[error("method {method:?} not valid in state {state:?}")]
MethodNotValidInState {
method: Method,
state: SessionState,
},
#[error("response is missing a CSeq header")]
MissingCSeq,
#[error("invalid Transport header: {0}")]
TransportParse(String),
#[error("cannot serialize header: {0}")]
HeaderSerialize(String),
#[error("invalid Session header: {0}")]
SessionParse(String),
#[error("invalid interleaved frame: {0}")]
InterleavedFrame(String),
#[error("authentication failure: {0}")]
Auth(#[from] broadcast_auth::Error),
#[error("authentication failure: 401 without WWW-Authenticate")]
MissingAuthChallenge,
#[error("socket IO error: {0}")]
Io(String),
#[error("timed out waiting for {what}")]
Timeout {
what: &'static str,
},
#[error("TLS error: {0}")]
Tls(String),
#[error("RTSP session not found (454 {method:?}): the session is gone; re-SETUP")]
SessionNotFound {
method: Method,
},
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(e.to_string())
}
}