pub struct UnknownTag<'a> { /* private fields */ }Expand description
A tag that is unknown to the library found during parsing input data.
This may be because the tag is truly unknown (i.e., is not one of the 32 supported HLS defined
tags), or because the known tag has been ignored via crate::config::ParsingOptions, or also
if there was an error in parsing the known tag. In the last case, the Self::validation_error
will provide details on the problem encountered.
Despite not being “fully parsed”, the TagValue provided in Self::value provides many
methods useful for extracting more information from the tag value, and is what all the library
defined HLS tags use to parse into more strongly defined data structures.
For example:
let lines = r#"#EXT-X-QUESTION:VALUE="Do you know who I am?"
#EXT-X-PROGRAM-DATE-TIME:2025-08-05T21:59:42.417-05:00
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=10000000"#;
let mut reader = Reader::from_str(
lines,
ParsingOptionsBuilder::new()
.with_parsing_for_stream_inf()
.build()
);
// #EXT-X-QUESTION:VALUE="Do you know who I am?"
let Ok(Some(HlsLine::UnknownTag(tag))) = reader.read_line() else { panic!("unexpected tag") };
assert_eq!("-X-QUESTION", tag.name());
assert_eq!(Some(TagValue(r#"VALUE="Do you know who I am?""#.as_bytes())), tag.value());
assert_eq!(None, tag.validation_error());
assert_eq!(r#"#EXT-X-QUESTION:VALUE="Do you know who I am?""#.as_bytes(), tag.as_bytes());
// #EXT-X-PROGRAM-DATE-TIME:2025-08-05T21:59:42.417-05:00
let Ok(Some(HlsLine::UnknownTag(tag))) = reader.read_line() else { panic!("unexpected tag") };
assert_eq!("-X-PROGRAM-DATE-TIME", tag.name());
assert_eq!(Some(TagValue("2025-08-05T21:59:42.417-05:00".as_bytes())), tag.value());
assert_eq!(None, tag.validation_error());
assert_eq!(
"#EXT-X-PROGRAM-DATE-TIME:2025-08-05T21:59:42.417-05:00".as_bytes(),
tag.as_bytes()
);
// #EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=10000000
let Ok(Some(HlsLine::UnknownTag(tag))) = reader.read_line() else { panic!("unexpected tag") };
assert_eq!("-X-STREAM-INF", tag.name());
assert_eq!(Some(TagValue("AVERAGE-BANDWIDTH=10000000".as_bytes())), tag.value());
assert_eq!(
Some(ValidationError::MissingRequiredAttribute("BANDWIDTH")),
tag.validation_error()
);
assert_eq!(
"#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=10000000".as_bytes(),
tag.as_bytes()
);Implementations§
Source§impl<'a> UnknownTag<'a>
impl<'a> UnknownTag<'a>
Sourcepub fn name(&self) -> &'a str
pub fn name(&self) -> &'a str
The name of the unknown tag.
This includes everything after the #EXT prefix and before the : or new line. For
example, #EXTM3U has name M3U, #EXT-X-VERSION:3 has name -X-VERSION, etc.
Sourcepub fn value(&self) -> Option<TagValue<'a>>
pub fn value(&self) -> Option<TagValue<'a>>
The value of the unknown tag.
This will be the entire byte-slice after the first : in the line. If there is no : then
this will be None. The slice borrow is wrapped in TagValue which provides many methods
for converting to a more suitable data structure depending on the tag. See the documentation
for TagValue for more information.
Sourcepub fn validation_error(&self) -> Option<ValidationError>
pub fn validation_error(&self) -> Option<ValidationError>
The error that led to this tag being unknown.
This value is only Some if the tag is unknown as the result of a problem in parsing a
known tag.
Trait Implementations§
Source§impl<'a> Clone for UnknownTag<'a>
impl<'a> Clone for UnknownTag<'a>
Source§fn clone(&self) -> UnknownTag<'a>
fn clone(&self) -> UnknownTag<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more