use crate::Method;
use crate::state::SessionState;
pub type Result<T> = core::result::Result<T, Error>;
#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
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("no pending request for CSeq {0}")]
UnknownCSeq(u32),
#[error("response is missing a CSeq header")]
MissingCSeq,
#[error("no session established (SETUP not completed)")]
MissingSession,
#[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(String),
#[error("request URI required but not set")]
MissingRequestUri,
#[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())
}
}