From 070a62f9ad6592126632df2c0c59ea684cdf5363 Mon Sep 17 00:00:00 2001 From: Luro02 <24826124+Luro02@users.noreply.github.com> Date: Fri, 21 Feb 2020 20:42:44 +0100 Subject: [PATCH] improvements to ClosedCaptions --- src/types/closed_captions.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/types/closed_captions.rs b/src/types/closed_captions.rs index ae2350b..0948b13 100644 --- a/src/types/closed_captions.rs +++ b/src/types/closed_captions.rs @@ -19,7 +19,7 @@ pub enum ClosedCaptions { /// [`ExtXMedia::media_type`]: crate::tags::ExtXMedia::media_type /// [`MediaType::ClosedCaptions`]: crate::types::MediaType::ClosedCaptions GroupId(String), - /// [`ClosedCaptions::None`] indicates that there are no closed captions in + /// This variant indicates that there are no closed captions in /// any [`VariantStream`] in the [`MasterPlaylist`], therefore all /// [`VariantStream::ExtXStreamInf`] tags must have this attribute with a /// value of [`ClosedCaptions::None`]. @@ -34,6 +34,34 @@ pub enum ClosedCaptions { None, } +impl ClosedCaptions { + /// Creates a [`ClosedCaptions::GroupId`] with the provided [`String`]. + /// + /// # Example + /// + /// ``` + /// use hls_m3u8::types::ClosedCaptions; + /// + /// assert_eq!( + /// ClosedCaptions::group_id("vg1"), + /// ClosedCaptions::GroupId("vg1".into()) + /// ); + /// ``` + pub fn group_id>(value: I) -> Self { + // + Self::GroupId(value.into()) + } +} + +impl> PartialEq for ClosedCaptions { + fn eq(&self, other: &T) -> bool { + match &self { + Self::GroupId(value) => other.eq(value), + Self::None => other.eq("NONE"), + } + } +} + impl fmt::Display for ClosedCaptions { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self {