1extern crate alloc;
4
5use alloc::string::String;
6use thiserror::Error;
7
8pub type Result<T> = core::result::Result<T, Error>;
10
11#[derive(Debug, Error)]
13#[non_exhaustive]
14pub enum Error {
15 #[error("XML parse error: {0}")]
17 XmlParse(String),
18
19 #[error("expected root element <tt> in namespace http://www.w3.org/ns/ttml, got {0}")]
21 NotTtmlRoot(String),
22
23 #[error("missing required element: {0}")]
25 MissingElement(&'static str),
26
27 #[error("missing required attribute '{attr}' on element '{element}'")]
29 MissingAttribute {
30 element: &'static str,
32 attr: &'static str,
34 },
35
36 #[error("invalid value for attribute '{attr}' on element '{element}': {reason}")]
38 InvalidAttribute {
39 element: &'static str,
41 attr: &'static str,
43 reason: String,
45 },
46
47 #[error("invalid time expression '{value}': {reason}")]
49 InvalidTimeExpression {
50 value: String,
52 reason: String,
54 },
55
56 #[error("IMSC validation error: {0}")]
58 Validation(String),
59
60 #[error("unexpected element '{name}' in namespace '{ns}'")]
62 UnexpectedElement {
63 name: String,
65 ns: String,
67 },
68
69 #[error("prohibited element '{name}' for the claimed profile")]
71 ProhibitedElement {
72 name: String,
74 },
75
76 #[error("prohibited attribute '{attr}' for the claimed profile")]
78 ProhibitedAttribute {
79 attr: String,
81 },
82
83 #[error("{constraint}: {detail}")]
85 ConstraintViolation {
86 constraint: String,
88 detail: String,
90 },
91
92 #[error("serialization error: {0}")]
94 Serialize(String),
95}