ferro_blob_store/error.rs
1// SPDX-License-Identifier: Apache-2.0
2//! Error types.
3
4use thiserror::Error;
5
6use crate::digest::DigestParseError;
7
8/// Errors emitted by [`crate::BlobStore`] implementations.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum BlobStoreError {
12 /// I/O error while reading from or writing to the backing store.
13 #[error("io: {0}")]
14 Io(#[from] std::io::Error),
15
16 /// The bytes supplied to [`crate::BlobStore::put`] did not match
17 /// the supplied [`crate::Digest`].
18 #[error("digest mismatch on put: caller said {expected}, computed {computed}")]
19 DigestMismatch {
20 /// Digest the caller asserted.
21 expected: String,
22 /// Digest the implementation computed from the supplied bytes.
23 computed: String,
24 },
25
26 /// No blob exists for the supplied [`crate::Digest`].
27 #[error("blob not found: {0}")]
28 NotFound(String),
29
30 /// A wire `<algo>:<hex>` string failed to parse.
31 #[error("invalid digest: {0}")]
32 InvalidDigest(#[from] DigestParseError),
33}