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>
impl<T> EnumeratedString<'_, T>
Source§impl<'a, T> EnumeratedString<'a, T>where
T: AsStaticCow,
impl<'a, T> EnumeratedString<'a, T>where
T: AsStaticCow,
Sourcepub fn as_cow(&self) -> Cow<'a, str>
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>
impl<'a, T: Clone> Clone for EnumeratedString<'a, T>
Source§fn clone(&self) -> EnumeratedString<'a, T>
fn clone(&self) -> EnumeratedString<'a, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more