1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5 #[error(transparent)]
6 Io(#[from] std::io::Error),
7 #[cfg(feature = "sqlx-store")]
8 #[error(transparent)]
9 Sql(#[from] sqlx::Error),
10 #[cfg(any(feature = "sqlite-pack", feature = "rusqlite-store"))]
11 #[error(transparent)]
12 Rusqlite(#[from] rusqlite::Error),
13 #[error("invalid hash length: {0}, expected 32 bytes")]
14 InvalidHashLength(usize),
15 #[error("invalid hex encoding: {0}")]
16 InvalidHex(String),
17 #[error("invalid fastcdc parameters")]
18 InvalidCdcParams,
19 #[error("compress failed: {0}")]
20 Compress(String),
21 #[error("decompress failed: {0}")]
22 Decompress(String),
23 #[error("invalid codec value {0}")]
24 InvalidCodec(String),
25 #[error("merkle meta missing {0}")]
26 MissingMeta(String),
27 #[error("hash mismatch when writing object")]
28 HashMismatch,
29 #[error("object decoded length mismatch: expected {expected}, got {actual}")]
30 ObjectLengthMismatch { expected: u64, actual: u64 },
31 #[error("object hash mismatch: expected {expected}, got {actual}")]
32 ObjectHashMismatch { expected: crate::Hash32, actual: crate::Hash32 },
33 #[error("sqlite integrity_check failed: {0}")]
34 Integrity(String),
35 #[error("object not found")]
36 ObjectNotFound,
37 #[error("invalid config: {0}")]
38 InvalidConfig(String),
39 #[error("generic error: {0}")]
40 Other(String),
41 #[error("invalid sealed pack: {0}")]
42 InvalidSealed(String),
43 #[error("sealed pack authentication failed")]
44 AuthenticationFailed,
45 #[error("duplicate transform decoder {id} version {version}")]
46 DuplicateTransformDecoder { id: u16, version: u16 },
47 #[error("unsupported transform {id} version {version}")]
48 UnsupportedTransform { id: u16, version: u16 },
49 #[error("object {hash} has kind {actual:?}, expected {expected:?}")]
50 ObjectKindMismatch {
51 hash: crate::Hash32,
52 expected: crate::ObjectKind,
53 actual: crate::ObjectKind,
54 },
55 #[error("recipe chunk {hash} length mismatch: expected {expected}, got {actual}")]
56 RecipeChunkLengthMismatch { hash: crate::Hash32, expected: u64, actual: u64 },
57 #[error("invalid recipe: {0}")]
58 InvalidRecipe(String),
59 #[error("file read limit {limit} exceeded: maximum {maximum}, actual {actual}")]
60 FileReadLimitExceeded { limit: &'static str, maximum: u64, actual: u64 },
61 #[error("unable to allocate {requested} bytes for {buffer}")]
62 FileReadAllocationFailed { buffer: &'static str, requested: u64 },
63 #[error("original file mismatch")]
64 OriginalFileMismatch {
65 expected_size: u64,
66 actual_size: u64,
67 expected_hash: crate::Hash32,
68 actual_hash: crate::Hash32,
69 },
70}
71
72pub type Result<T> = std::result::Result<T, Error>;