Skip to main content

broadcast_hls/
error.rs

1//! Error type returned by playlist parsing.
2
3use alloc::string::String;
4use thiserror::Error;
5
6/// Crate-wide result alias.
7pub type Result<T> = core::result::Result<T, Error>;
8
9/// Error variants that [`crate::MediaPlaylist::parse`]/[`crate::MasterPlaylist::parse`]
10/// can return.
11#[derive(Debug, Error, PartialEq, Eq)]
12#[non_exhaustive]
13pub enum Error {
14    /// An HLS playlist (`.m3u8`, RFC 8216bis) tag could not be parsed —
15    /// [`crate::MediaPlaylist::parse`]/[`crate::MasterPlaylist::parse`]'s
16    /// `to_m3u8()` renderers' symmetric inverse. Unrecognized tags are
17    /// ignored (forward-compat); this variant is only returned for a
18    /// *known* tag whose required attribute is missing or whose value
19    /// fails to parse.
20    #[error("hls parse (line {line_no}): {reason}\n  {line}")]
21    HlsParse {
22        /// 1-based line number within the input playlist text.
23        line_no: usize,
24        /// The offending line, verbatim.
25        line: String,
26        /// Human-readable explanation.
27        reason: String,
28    },
29}