2019-09-06 10:55:00 +00:00
|
|
|
use std::fmt;
|
|
|
|
use std::str::FromStr;
|
|
|
|
|
2019-10-04 09:02:21 +00:00
|
|
|
use crate::types::ProtocolVersion;
|
2019-09-13 14:06:52 +00:00
|
|
|
use crate::utils::tag;
|
2019-10-04 09:02:21 +00:00
|
|
|
use crate::{Error, RequiredVersion};
|
2019-09-13 14:06:52 +00:00
|
|
|
|
2019-09-22 16:00:38 +00:00
|
|
|
/// # [4.4.3.4. EXT-X-ENDLIST]
|
2019-10-03 14:23:27 +00:00
|
|
|
/// The [`ExtXEndList`] tag indicates, that no more [`Media Segment`]s will be
|
|
|
|
/// added to the [`Media Playlist`] file.
|
2019-09-06 10:55:00 +00:00
|
|
|
///
|
2019-09-22 16:00:38 +00:00
|
|
|
/// Its format is:
|
|
|
|
/// ```text
|
|
|
|
/// #EXT-X-ENDLIST
|
|
|
|
/// ```
|
|
|
|
///
|
2019-10-03 14:23:27 +00:00
|
|
|
/// [`Media Segment`]: crate::MediaSegment
|
|
|
|
/// [`Media Playlist`]: crate::MediaPlaylist
|
2019-09-22 16:00:38 +00:00
|
|
|
/// [4.4.3.4. EXT-X-ENDLIST]:
|
|
|
|
/// https://tools.ietf.org/html/draft-pantos-hls-rfc8216bis-04#section-4.4.3.4
|
2019-09-06 10:55:00 +00:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
|
|
pub struct ExtXEndList;
|
2019-09-22 08:57:28 +00:00
|
|
|
|
2019-09-06 10:55:00 +00:00
|
|
|
impl ExtXEndList {
|
|
|
|
pub(crate) const PREFIX: &'static str = "#EXT-X-ENDLIST";
|
2019-09-22 08:57:28 +00:00
|
|
|
}
|
2019-09-06 10:55:00 +00:00
|
|
|
|
2019-09-22 08:57:28 +00:00
|
|
|
impl RequiredVersion for ExtXEndList {
|
2019-10-03 15:01:15 +00:00
|
|
|
fn required_version(&self) -> ProtocolVersion { ProtocolVersion::V1 }
|
2019-09-06 10:55:00 +00:00
|
|
|
}
|
2019-09-08 10:23:33 +00:00
|
|
|
|
2019-09-06 10:55:00 +00:00
|
|
|
impl fmt::Display for ExtXEndList {
|
2019-10-03 15:01:15 +00:00
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Self::PREFIX.fmt(f) }
|
2019-09-06 10:55:00 +00:00
|
|
|
}
|
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-10-05 14:08:03 +00:00
|
|
|
Ok(Self)
|
2019-09-06 10:55:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
2019-10-08 13:42:33 +00:00
|
|
|
use pretty_assertions::assert_eq;
|
2019-09-06 10:55:00 +00:00
|
|
|
|
|
|
|
#[test]
|
2019-09-22 08:57:28 +00:00
|
|
|
fn test_display() {
|
|
|
|
assert_eq!(ExtXEndList.to_string(), "#EXT-X-ENDLIST".to_string());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parser() {
|
|
|
|
assert_eq!(ExtXEndList, "#EXT-X-ENDLIST".parse().unwrap());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_required_version() {
|
|
|
|
assert_eq!(ExtXEndList.required_version(), ProtocolVersion::V1);
|
2019-09-06 10:55:00 +00:00
|
|
|
}
|
|
|
|
}
|