1use crate::hash::Hash;
4
5#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 #[error("i/o error: {0}")]
9 Io(#[from] std::io::Error),
10
11 #[error("serialization failed: {0}")]
12 Serialize(String),
13
14 #[error("deserialization failed: {0}")]
15 Deserialize(String),
16
17 #[error("compression failed: {0}")]
18 Compression(String),
19
20 #[error("not a valid gpp object: bad magic bytes")]
21 BadMagic,
22
23 #[error("unsupported object wire-format version: {0}")]
24 UnsupportedVersion(u8),
25
26 #[error("unknown object type code: {0}")]
27 UnknownObjectType(u8),
28
29 #[error("object type mismatch: expected {expected}, found {found}")]
30 TypeMismatch { expected: u8, found: u8 },
31
32 #[error("frame is truncated or malformed")]
33 TruncatedFrame,
34
35 #[error("payload checksum mismatch (object is corrupt)")]
36 ChecksumMismatch,
37
38 #[error("hash verification failed: expected {expected}, computed {computed}")]
39 HashMismatch { expected: Hash, computed: Hash },
40
41 #[error("invalid hash string: {0}")]
42 InvalidHash(String),
43
44 #[error("object not found: {0}")]
45 NotFound(Hash),
46}
47
48pub type Result<T> = std::result::Result<T, Error>;