1use bytes::Bytes;
6
7pub type Result<T> = std::result::Result<T, Error>;
9
10#[derive(Debug, thiserror::Error)]
12#[non_exhaustive]
13pub enum Error {
14 #[error("unexpected value type: {0}")]
15 InvalidValueType(&'static str),
16 #[error("missing `{0}` element")]
17 MissingElement(&'static str),
18 #[error("empty `{0}` element")]
19 EmptyElement(&'static str),
20 #[error("conflicting elements: {0}")]
21 ConflictingElements(&'static str),
22 #[error("invalid namespace declaration: {0:?}")]
23 InvalidNamespace(Bytes),
24 #[error(transparent)]
25 Xml(#[from] quick_xml::Error),
26 #[error("unexpected tag")]
27 UnexpectedTag,
28 #[error(transparent)]
29 Utf8(#[from] std::str::Utf8Error),
30 #[error(transparent)]
31 Other(#[from] Box<dyn std::error::Error + Send + Sync>),
32}
33
34impl Error {
35 pub fn other(e: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> Self {
36 Self::Other(e.into())
37 }
38}