sheathe_core/error.rs
1//! The crate-wide error type, re-exported from the workspace root.
2
3/// Convenient alias used throughout the sheathe crates.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Errors produced while parsing, packaging, or muxing media.
7#[derive(Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum Error {
10 /// An underlying I/O failure.
11 #[error("i/o error: {0}")]
12 Io(#[from] std::io::Error),
13
14 /// The input bitstream or container was malformed.
15 #[error("malformed input: {0}")]
16 Malformed(String),
17
18 /// A feature, codec, or container variant is recognised but not yet implemented.
19 #[error("unsupported: {0}")]
20 Unsupported(String),
21
22 /// A configuration or CLI argument was invalid.
23 #[error("invalid configuration: {0}")]
24 Config(String),
25}
26
27impl Error {
28 /// Construct a [`Error::Malformed`] from anything string-like.
29 pub fn malformed(msg: impl Into<String>) -> Self {
30 Error::Malformed(msg.into())
31 }
32
33 /// Construct an [`Error::Unsupported`] from anything string-like.
34 pub fn unsupported(msg: impl Into<String>) -> Self {
35 Error::Unsupported(msg.into())
36 }
37}