av_stream_info_rust/
streamcheckresult.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
use crate::StreamCheckError;
use crate::StreamInfo;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum UrlType {
    Stream(StreamInfo),
    Playlist(Vec<String>),
}

/// A check result for a single url
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct StreamCheckResult {
    url: String,
    pub info: Result<UrlType, StreamCheckError>,
}

impl StreamCheckResult {
    pub fn new(url: &str, info: Result<UrlType, StreamCheckError>) -> Self {
        StreamCheckResult {
            url: url.to_string(),
            info,
        }
    }

    pub fn url(&self) -> &str {
        &self.url
    }
}