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.