1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-07-01 10:10:32 +00:00
hls_m3u8/src/tags/media_playlist/end_list.rs

50 lines
1.2 KiB
Rust
Raw Normal View History

2019-09-06 10:55:00 +00:00
use std::fmt;
use std::str::FromStr;
2019-09-13 14:06:52 +00:00
use crate::types::ProtocolVersion;
use crate::utils::tag;
use crate::Error;
2019-09-06 10:55:00 +00:00
/// [4.3.3.4. EXT-X-ENDLIST]
///
/// [4.3.3.4. EXT-X-ENDLIST]: https://tools.ietf.org/html/rfc8216#section-4.3.3.4
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ExtXEndList;
impl ExtXEndList {
pub(crate) const PREFIX: &'static str = "#EXT-X-ENDLIST";
/// Returns the protocol compatibility version that this tag requires.
2019-09-08 10:23:33 +00:00
pub const fn requires_version(self) -> ProtocolVersion {
2019-09-06 10:55:00 +00:00
ProtocolVersion::V1
}
}
2019-09-08 10:23:33 +00:00
2019-09-06 10:55:00 +00:00
impl fmt::Display for ExtXEndList {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Self::PREFIX.fmt(f)
}
}
2019-09-08 10:23:33 +00:00
2019-09-06 10:55:00 +00:00
impl FromStr for ExtXEndList {
type Err = Error;
2019-09-08 10:23:33 +00:00
2019-09-13 14:06:52 +00:00
fn from_str(input: &str) -> Result<Self, Self::Err> {
tag(input, Self::PREFIX)?;
2019-09-06 10:55:00 +00:00
Ok(ExtXEndList)
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn ext_x_endlist() {
let tag = ExtXEndList;
let text = "#EXT-X-ENDLIST";
assert_eq!(text.parse().ok(), Some(tag));
assert_eq!(tag.to_string(), text);
assert_eq!(tag.requires_version(), ProtocolVersion::V1);
}
}