WritableTagValue

Enum WritableTagValue 

Source
pub enum WritableTagValue<'a> {
    Empty,
    DecimalInteger(u64),
    DecimalIntegerRange(u64, Option<u64>),
    DecimalFloatingPointWithOptionalTitle(f64, Cow<'a, str>),
    DateTime(DateTime),
    AttributeList(HashMap<Cow<'a, str>, WritableAttributeValue<'a>>),
    Utf8(Cow<'a, str>),
}
Expand description

Provides a writable version of TagValue.

This is provided so that custom tag implementations may provide an output that does not depend on having parsed data to derive the write output from. This helps with mutability as well as allowing for custom tags to be constructed from scratch (without being parsed from source data).

While TagValue is just a wrapper around a borrowed slice of bytes, WritableTagValue is an enumeration of different value types, as this helps keep converting from a custom tag more easy (otherwise all users of the library would need to manage re-constructing the playlist line directly).

Variants§

§

Empty

The value is empty.

For example, the #EXTM3U tag has an Empty value.

§

DecimalInteger(u64)

The value is a decimal integer.

For example, the #EXT-X-VERSION:<n> tag has a DecimalInteger value (e.g. #EXT-X-VERSION:9).

§

DecimalIntegerRange(u64, Option<u64>)

The value is a decimal integer range.

For example, the #EXT-X-BYTERANGE:<n>[@<o>] tag has a DecimalIntegerRange value (e.g. #EXT-X-BYTERANGE:4545045@720).

§

DecimalFloatingPointWithOptionalTitle(f64, Cow<'a, str>)

The value is a float with a string title.

For example, the #EXTINF:<duration>,[<title>] tag has a DecimalFloatingPointWithOptionalTitle value (e.g. #EXTINF:3.003,free-form text).

If the title provided is empty ("") then the comma will not be written.

§

DateTime(DateTime)

The value is a date time.

For example, the #EXT-X-PROGRAM-DATE-TIME:<date-time-msec> tag has a DateTime value (e.g. #EXT-X-PROGRAM-DATE-TIME:2010-02-19T14:54:23.031+08:00).

§

AttributeList(HashMap<Cow<'a, str>, WritableAttributeValue<'a>>)

The value is an attribute list.

For example, the #EXT-X-MAP:<attribute-list> tag has an AttributeList value (e.g. #EXT-X-MAP:URI="init.mp4").

§

Utf8(Cow<'a, str>)

The value is a UTF-8 string.

For example, the #EXT-X-PLAYLIST-TYPE:<type-enum> tag has a Utf8 value (e.g. #EXT-X-PLAYLIST-TYPE:VOD).

Note, this effectively provides the user of the library an “escape hatch” to write any value that they want.

Also note, the library does not validate for correctness of the input value, so take care to not introduce new lines or invalid characters (e.g. whitespace) as this will lead to an invalid HLS playlist.

Trait Implementations§

Source§

impl<'a> Debug for WritableTagValue<'a>

Source§

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

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

impl<'a> From<&'a str> for WritableTagValue<'a>

Source§

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

Converts to this type from the input type.
Source§

impl<'a, K, V, const N: usize> From<[(K, V); N]> for WritableTagValue<'a>
where K: Into<Cow<'a, str>>, V: Into<WritableAttributeValue<'a>>,

Source§

fn from(value: [(K, V); N]) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<(f64, T)> for WritableTagValue<'a>
where T: Into<Cow<'a, str>>,

Source§

fn from(value: (f64, T)) -> Self

Converts to this type from the input type.
Source§

impl From<(u64, Option<u64>)> for WritableTagValue<'_>

Source§

fn from(value: (u64, Option<u64>)) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Cow<'a, str>> for WritableTagValue<'a>

Source§

fn from(value: Cow<'a, str>) -> Self

Converts to this type from the input type.
Source§

impl From<DateTime> for WritableTagValue<'_>

Source§

fn from(value: DateTime) -> Self

Converts to this type from the input type.
Source§

impl<'a, K, V> From<HashMap<K, V>> for WritableTagValue<'a>
where K: Into<Cow<'a, str>>, V: Into<WritableAttributeValue<'a>>,

Source§

fn from(value: HashMap<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<String> for WritableTagValue<'a>

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for WritableTagValue<'_>

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl<'a> PartialEq for WritableTagValue<'a>

Source§

fn eq(&self, other: &WritableTagValue<'a>) -> 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> StructuralPartialEq for WritableTagValue<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for WritableTagValue<'a>

§

impl<'a> RefUnwindSafe for WritableTagValue<'a>

§

impl<'a> Send for WritableTagValue<'a>

§

impl<'a> Sync for WritableTagValue<'a>

§

impl<'a> Unpin for WritableTagValue<'a>

§

impl<'a> UnwindSafe for WritableTagValue<'a>

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> 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, 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.