mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-06-03 05:59:22 +00:00
38 lines
905 B
Rust
38 lines
905 B
Rust
use std::fmt;
|
|
use std::str::FromStr;
|
|
|
|
use crate::Error;
|
|
|
|
/// Playlist type.
|
|
///
|
|
/// See: [4.3.3.5. EXT-X-PLAYLIST-TYPE]
|
|
///
|
|
/// [4.3.3.5. EXT-X-PLAYLIST-TYPE]: https://tools.ietf.org/html/rfc8216#section-4.3.3.5
|
|
#[allow(missing_docs)]
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
pub enum PlaylistType {
|
|
Event,
|
|
Vod,
|
|
}
|
|
|
|
impl fmt::Display for PlaylistType {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
match *self {
|
|
PlaylistType::Event => write!(f, "EVENT"),
|
|
PlaylistType::Vod => write!(f, "VOD"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl FromStr for PlaylistType {
|
|
type Err = Error;
|
|
|
|
fn from_str(input: &str) -> Result<Self, Self::Err> {
|
|
match input {
|
|
"EVENT" => Ok(PlaylistType::Event),
|
|
"VOD" => Ok(PlaylistType::Vod),
|
|
_ => Err(Error::custom(format!("Unknown playlist type: {:?}", input))),
|
|
}
|
|
}
|
|
}
|