av_stream_info_rust/
streamcheckerror.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use std::error::Error;
use std::fmt;

use serde::{Deserialize, Serialize};

/// Posible errors for stream checking.
/// First parameter is the url.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum StreamCheckError {
    ConnectionFailed(),
    IllegalStatusCode(u32),
    MaxDepthReached(),
    MissingContentType(),
    PlayListDecodeError(),
    PlaylistEmpty(),
    PlaylistReadFailed(),
    UnknownContentType(String),
    UrlJoinError(),
    UrlParseError(),
    NoLocationFieldForRedirect(),
    NoResult(),
}

impl fmt::Display for StreamCheckError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            StreamCheckError::ConnectionFailed() => write!(f, "ConnectionFailed()"),
            StreamCheckError::IllegalStatusCode(code) => write!(f, "IllegalStatusCode({})", code),
            StreamCheckError::MaxDepthReached() => write!(f, "MaxDepthReached()"),
            StreamCheckError::MissingContentType() => write!(f, "MissingContentType()"),
            StreamCheckError::PlayListDecodeError() => write!(f, "PlayListDecodeError()"),
            StreamCheckError::PlaylistEmpty() => write!(f, "PlaylistEmpty()"),
            StreamCheckError::PlaylistReadFailed() => write!(f, "PlaylistReadFailed()"),
            StreamCheckError::UnknownContentType(content_type) => write!(f, "UnknownContentType({})", content_type),
            StreamCheckError::UrlJoinError() => write!(f, "UrlJoinError()"),
            StreamCheckError::UrlParseError() => write!(f, "UrlParseError()"),
            StreamCheckError::NoLocationFieldForRedirect() => write!(f, "NoLocationFieldForRedirect()"),
            StreamCheckError::NoResult() => write!(f, "NoResult()"),
        }
    }
}

impl Error for StreamCheckError {}