av_stream_info_rust/
streamcheckerror.rs

1use std::error::Error;
2use std::fmt;
3
4use serde::{Deserialize, Serialize};
5
6/// Posible errors for stream checking.
7/// First parameter is the url.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub enum StreamCheckError {
10    ConnectionFailed(),
11    IllegalStatusCode(u32),
12    MaxDepthReached(),
13    MissingContentType(),
14    PlayListDecodeError(),
15    PlaylistEmpty(),
16    PlaylistReadFailed(),
17    UnknownContentType(String),
18    UrlJoinError(),
19    UrlParseError(),
20    NoLocationFieldForRedirect(),
21    NoResult(),
22}
23
24impl fmt::Display for StreamCheckError {
25    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
26        match self {
27            StreamCheckError::ConnectionFailed() => write!(f, "ConnectionFailed()"),
28            StreamCheckError::IllegalStatusCode(code) => write!(f, "IllegalStatusCode({})", code),
29            StreamCheckError::MaxDepthReached() => write!(f, "MaxDepthReached()"),
30            StreamCheckError::MissingContentType() => write!(f, "MissingContentType()"),
31            StreamCheckError::PlayListDecodeError() => write!(f, "PlayListDecodeError()"),
32            StreamCheckError::PlaylistEmpty() => write!(f, "PlaylistEmpty()"),
33            StreamCheckError::PlaylistReadFailed() => write!(f, "PlaylistReadFailed()"),
34            StreamCheckError::UnknownContentType(content_type) => write!(f, "UnknownContentType({})", content_type),
35            StreamCheckError::UrlJoinError() => write!(f, "UrlJoinError()"),
36            StreamCheckError::UrlParseError() => write!(f, "UrlParseError()"),
37            StreamCheckError::NoLocationFieldForRedirect() => write!(f, "NoLocationFieldForRedirect()"),
38            StreamCheckError::NoResult() => write!(f, "NoResult()"),
39        }
40    }
41}
42
43impl Error for StreamCheckError {}