1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-05-18 16:28:20 +00:00

improvements to ClosedCaptions

This commit is contained in:
Luro02 2020-02-21 20:42:44 +01:00
parent 30e8009af1
commit 070a62f9ad
No known key found for this signature in database
GPG key ID: B66FD4F74501A9CF

View file

@ -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<I: Into<String>>(value: I) -> Self {
//
Self::GroupId(value.into())
}
}
impl<T: PartialEq<str>> PartialEq<T> 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 {