1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-05-21 01:38:07 +00:00
hls_m3u8/src/types/media_type.rs

40 lines
1.1 KiB
Rust
Raw Normal View History

2019-09-22 18:33:40 +00:00
use strum::{Display, EnumString};
2019-09-06 11:20:40 +00:00
2019-09-22 18:33:40 +00:00
/// Specifies the media type.
2019-09-06 11:20:40 +00:00
#[allow(missing_docs)]
2019-09-22 18:33:40 +00:00
#[derive(Ord, PartialOrd, Display, EnumString, Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[strum(serialize_all = "SCREAMING-KEBAB-CASE")]
2019-09-06 11:20:40 +00:00
pub enum MediaType {
Audio,
Video,
Subtitles,
ClosedCaptions,
}
2019-09-22 18:33:40 +00:00
#[cfg(test)]
mod tests {
use super::*;
2019-09-06 11:20:40 +00:00
2019-09-22 18:33:40 +00:00
#[test]
fn test_parser() {
assert_eq!(MediaType::Audio, "AUDIO".parse().unwrap());
assert_eq!(MediaType::Video, "VIDEO".parse().unwrap());
assert_eq!(MediaType::Subtitles, "SUBTITLES".parse().unwrap());
assert_eq!(
MediaType::ClosedCaptions,
"CLOSED-CAPTIONS".parse().unwrap()
);
}
2019-09-13 14:06:52 +00:00
2019-09-22 18:33:40 +00:00
#[test]
fn test_display() {
assert_eq!(MediaType::Audio.to_string(), "AUDIO".to_string());
assert_eq!(MediaType::Video.to_string(), "VIDEO".to_string());
assert_eq!(MediaType::Subtitles.to_string(), "SUBTITLES".to_string());
assert_eq!(
MediaType::ClosedCaptions.to_string(),
"CLOSED-CAPTIONS".to_string()
);
2019-09-06 11:20:40 +00:00
}
}