1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Error, Debug)]
6pub enum Error {
7 #[error("Invalid magic bytes (expected VWH\\0)")]
8 InvalidMagic,
9
10 #[error("Unsupported version: {0}")]
11 UnsupportedVersion(u16),
12
13 #[error("Invalid intent value: {0}")]
14 InvalidIntent(u8),
15
16 #[error("Invalid intent string: {0}")]
17 InvalidIntentString(String),
18
19 #[error("Invalid artifact ID")]
20 InvalidArtifactId,
21
22 #[error("Invalid hex encoding")]
23 InvalidHex,
24
25 #[error("Signature verification failed")]
26 SignatureInvalid,
27
28 #[error("Artifact has no seal")]
29 NoSeal,
30
31 #[error("Key bytes are malformed or invalid")]
32 KeyMalformed,
33
34 #[error("File too small (minimum {expected} bytes, got {actual})")]
35 FileTooSmall { expected: usize, actual: usize },
36
37 #[error("Unexpected EOF while reading {field}")]
38 UnexpectedEof { field: String },
39
40 #[error("IO error: {0}")]
41 Io(#[from] std::io::Error),
42
43 #[error("JSON error: {0}")]
44 Json(#[from] serde_json::Error),
45
46 #[error("Invalid artifact state: expected {expected}, got {actual}")]
47 InvalidState { expected: &'static str, actual: &'static str },
48}
49