1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-05-17 16:02:59 +00:00
hls_m3u8/src/types/hdcp_level.rs

41 lines
1,011 B
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
/// HDCP level.
///
/// See: [4.3.4.2. EXT-X-STREAM-INF]
///
/// [4.3.4.2. EXT-X-STREAM-INF]: https://tools.ietf.org/html/rfc8216#section-4.3.4.2
#[allow(missing_docs)]
2019-09-22 18:33:40 +00:00
#[derive(Ord, PartialOrd, Debug, Clone, Copy, PartialEq, Eq, Hash, Display, EnumString)]
#[strum(serialize_all = "SCREAMING-KEBAB-CASE")]
2019-09-06 11:20:40 +00:00
pub enum HdcpLevel {
2019-09-22 18:33:40 +00:00
#[strum(serialize = "TYPE-0")]
2019-09-06 11:20:40 +00:00
Type0,
None,
}
2019-09-06 11:46:21 +00:00
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_display() {
let level = HdcpLevel::Type0;
assert_eq!(level.to_string(), "TYPE-0".to_string());
let level = HdcpLevel::None;
assert_eq!(level.to_string(), "NONE".to_string());
}
#[test]
2019-09-21 11:24:05 +00:00
fn test_parser() {
2019-09-06 11:46:21 +00:00
let level = HdcpLevel::Type0;
assert_eq!(level, "TYPE-0".parse::<HdcpLevel>().unwrap());
let level = HdcpLevel::None;
assert_eq!(level, "NONE".parse::<HdcpLevel>().unwrap());
2019-09-22 18:33:40 +00:00
assert!("unk".parse::<HdcpLevel>().is_err());
2019-09-06 11:46:21 +00:00
}
}