pf_core/error.rs
1// SPDX-License-Identifier: MIT
2//! Typed error hierarchy for `pf-core`.
3
4use std::io;
5
6/// All errors surfaced by `pf-core`.
7#[derive(Debug, thiserror::Error)]
8pub enum Error {
9 /// Wrapped I/O failure.
10 #[error("io: {0}")]
11 Io(#[from] io::Error),
12
13 /// JSON manifest (de)serialization failure.
14 #[error("manifest: {0}")]
15 Manifest(#[from] serde_json::Error),
16
17 /// Hex decoding failed.
18 #[error("hex: {0}")]
19 Hex(#[from] hex::FromHexError),
20
21 /// A digest was expected to have a specific length / format.
22 #[error("invalid digest: {0}")]
23 InvalidDigest(String),
24
25 /// CAS round-trip mismatch (data on disk does not hash to its key).
26 #[error("CAS integrity check failed for {0}")]
27 Integrity(String),
28
29 /// Catch-all for not-yet-implemented features in the Phase-0 scaffold.
30 #[error("not yet implemented: {0}")]
31 Unimplemented(&'static str),
32}
33
34/// `pf-core` result alias.
35pub type Result<T> = std::result::Result<T, Error>;