Enum EnumeratedString

Source
pub enum EnumeratedString<'a, T> {
    Known(T),
    Unknown(&'a str),
}
Expand description

Provides a forward compatible wrapper for enumerated string values.

The intent is that all cases of an enumerated string are captured within T; however, in case a new value is added to HLS and this library has not been updated to support it yet, this enum also supports an Unknown case that contains a custom string. In this way, parsing won’t break as new cases are added to the specification.

Note, that as long as T implements Into<Cow<str>>, then EnumeratedString<T> also implements Into<Cow<str>>. This is a convenience for when setting values on known tags. Also note that most library implementations of T will also implement From<T> for EnumeratedString<T>, which is another convenience for all methods that take some impl Into<EnumeratedString<T>>.

Variants§

§

Known(T)

The value is known to the library and provided by T.

§

Unknown(&'a str)

The value is unknown to the library but a reference to the original data is provided.

Implementations§

Source§

impl<T> EnumeratedString<'_, T>

Source

pub fn known(&self) -> Option<&T>

A convenience method for getting the known value. This may be most helpful when chaining on an already optional attribute.

Source§

impl<'a, T> EnumeratedString<'a, T>
where T: AsStaticCow,

Source

pub fn as_cow(&self) -> Cow<'a, str>

Provides the inner data as a std::borrow::Cow.

Trait Implementations§

Source§

impl<'a, T: Clone> Clone for EnumeratedString<'a, T>

Source§

fn clone(&self) -> EnumeratedString<'a, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, T: Debug> Debug for EnumeratedString<'a, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Display for EnumeratedString<'_, T>
where T: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T> From<&'a str> for EnumeratedString<'a, T>
where T: TryFrom<&'a str, Error = UnrecognizedEnumerationError<'a>>,

Source§

fn from(value: &'a str) -> Self

Converts to this type from the input type.
Source§

impl From<AudioCodingIdentifier> for EnumeratedString<'_, AudioCodingIdentifier>

Source§

fn from(value: AudioCodingIdentifier) -> Self

Converts to this type from the input type.
Source§

impl From<ChannelSpecialUsageIdentifier> for EnumeratedString<'_, ChannelSpecialUsageIdentifier>

Source§

fn from(value: ChannelSpecialUsageIdentifier) -> Self

Converts to this type from the input type.
Source§

impl From<Cue> for EnumeratedString<'_, Cue>

Source§

fn from(value: Cue) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<EnumeratedString<'a, T>> for Cow<'a, str>
where T: Into<Cow<'a, str>>,

Source§

fn from(value: EnumeratedString<'a, T>) -> Self

Converts to this type from the input type.
Source§

impl From<FairPlayCpcLabel> for EnumeratedString<'_, FairPlayCpcLabel>

Source§

fn from(value: FairPlayCpcLabel) -> Self

Converts to this type from the input type.
Source§

impl From<Format> for EnumeratedString<'_, Format>

Source§

fn from(value: Format) -> Self

Converts to this type from the input type.
Source§

impl From<HdcpLevel> for EnumeratedString<'_, HdcpLevel>

Source§

fn from(value: HdcpLevel) -> Self

Converts to this type from the input type.
Source§

impl From<InstreamId> for EnumeratedString<'_, InstreamId>

Source§

fn from(value: InstreamId) -> Self

Converts to this type from the input type.
Source§

impl From<MediaCharacteristicTag> for EnumeratedString<'_, MediaCharacteristicTag>

Source§

fn from(value: MediaCharacteristicTag) -> Self

Converts to this type from the input type.
Source§

impl From<MediaType> for EnumeratedString<'_, MediaType>

Source§

fn from(value: MediaType) -> Self

Converts to this type from the input type.
Source§

impl From<Method> for EnumeratedString<'_, Method>

Source§

fn from(value: Method) -> Self

Converts to this type from the input type.
Source§

impl From<PreloadHintType> for EnumeratedString<'_, PreloadHintType>

Source§

fn from(value: PreloadHintType) -> Self

Converts to this type from the input type.
Source§

impl From<VideoChannelSpecifier> for EnumeratedString<'_, VideoChannelSpecifier>

Source§

fn from(value: VideoChannelSpecifier) -> Self

Converts to this type from the input type.
Source§

impl From<VideoProjectionSpecifier> for EnumeratedString<'_, VideoProjectionSpecifier>

Source§

fn from(value: VideoProjectionSpecifier) -> Self

Converts to this type from the input type.
Source§

impl From<VideoRange> for EnumeratedString<'_, VideoRange>

Source§

fn from(value: VideoRange) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: PartialEq> PartialEq for EnumeratedString<'a, T>

Source§

fn eq(&self, other: &EnumeratedString<'a, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T: Copy> Copy for EnumeratedString<'a, T>

Source§

impl<'a, T> StructuralPartialEq for EnumeratedString<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for EnumeratedString<'a, T>
where T: Freeze,

§

impl<'a, T> RefUnwindSafe for EnumeratedString<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for EnumeratedString<'a, T>
where T: Send,

§

impl<'a, T> Sync for EnumeratedString<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for EnumeratedString<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for EnumeratedString<'a, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.