1use std::fmt;
2
3#[derive(Debug)]
5pub enum Error {
6 UnknownFormat,
8 Malformed(String),
10 NotFound,
12 EmptySource,
14 MalformedReference(String),
16 Io(std::io::Error),
17}
18
19impl fmt::Display for Error {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 Self::UnknownFormat => {
23 write!(f, "unrecognized ML model container format")
24 }
25 Self::Malformed(s) => write!(f, "malformed model container: {s}"),
26 Self::NotFound => write!(f, "no C2PA manifest found in model"),
27 Self::EmptySource => {
28 write!(f, "manifest source has neither an embedded store nor a URI")
29 }
30 Self::MalformedReference(s) => write!(f, "malformed manifest reference: {s}"),
31 Self::Io(e) => write!(f, "I/O error: {e}"),
32 }
33 }
34}
35
36impl std::error::Error for Error {}
37
38impl From<std::io::Error> for Error {
39 fn from(e: std::io::Error) -> Self {
40 Self::Io(e)
41 }
42}