Skip to main content

timed_metadata/
error.rs

1//! Crate error type.
2use alloc::string::String;
3
4/// Errors produced by conversions and the [`crate::Timeline`] session.
5#[derive(Debug, thiserror::Error)]
6#[non_exhaustive]
7pub enum Error {
8    /// A wall-clock conversion was attempted without a [`crate::TimeAnchor`].
9    #[error("wall-clock conversion requires a TimeAnchor, but none was set")]
10    MissingAnchor,
11    /// An emsg presented to [`crate::convert::emsg_to_scte35`] is not a
12    /// SCTE-35 carriage scheme.
13    #[error("emsg scheme {scheme:?} is not a SCTE-35 carriage scheme")]
14    UnsupportedScheme { scheme: String },
15    /// SCTE-35 parse failure.
16    #[error("SCTE-35: {0}")]
17    Scte35(#[from] scte35_splice::Error),
18    /// emsg parse/serialize failure.
19    #[error("emsg: {0}")]
20    Emsg(#[from] mp4_emsg::Error),
21    /// `EXT-X-DATERANGE` tag could not be parsed.
22    #[error("DATERANGE parse: {0}")]
23    AttrParse(String),
24    /// emsg ↔ SegmentTiming `timescale` mismatch.
25    #[error("emsg timescale ({emsg}) does not match SegmentTiming timescale ({timing})")]
26    EmsgTimescaleMismatch { emsg: u32, timing: u32 },
27    /// v0 emsg cannot carry an event starting before the segment EPT.
28    #[error("presentation time precedes earliest presentation time; cannot express as v0 delta")]
29    EmsgPresentationTimeBeforeEpt,
30    /// v0 `presentation_time_delta` overflowed u32.
31    #[error("presentation_time_delta value {0} exceeds u32 max")]
32    EmsgDeltaOverflow(u64),
33}
34
35/// Crate result alias.
36pub type Result<T> = core::result::Result<T, Error>;