iroh_db_blobs/
lib.rs

1//! Encrypted content-addressed blob manifests and streams for iroh-db.
2
3#![forbid(unsafe_code)]
4
5mod engine;
6mod local;
7mod model;
8mod scheduler;
9mod stream;
10
11pub use engine::{BlobEngine, FetchMetrics, FetchOptions};
12pub use local::{BlobProtocol, IrohBlobStore};
13pub use model::BlobRef;
14pub use scheduler::{BlobPriority, FetchScheduler, ProviderMetrics};
15pub use stream::BlobStream;
16
17/// Encrypted manifest, chunk, streaming or storage failure.
18#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
19pub enum BlobError {
20    /// The immutable blob repository failed.
21    #[error("blob repository failed: {0}")]
22    Store(String),
23    /// A referenced immutable object was absent locally.
24    #[error("blob is not available locally: {0}")]
25    MissingBlob(iroh_db_core::BlobHash),
26    /// Bytes did not match their content address.
27    #[error("blob content hash mismatch")]
28    HashMismatch,
29    /// The reference belongs to another domain or epoch.
30    #[error("blob reference belongs to another domain or epoch")]
31    WrongDomainOrEpoch,
32    /// An encrypted object failed AEAD authentication.
33    #[error("blob authentication failed")]
34    AuthenticationFailed,
35    /// Encryption failed.
36    #[error("blob encryption failed")]
37    EncryptionFailed,
38    /// A domain-separated object key could not be derived.
39    #[error("blob key derivation failed")]
40    KeyDerivationFailed,
41    /// A manifest violated canonical format or structural invariants.
42    #[error("blob manifest is invalid")]
43    InvalidManifest,
44    /// A canonical blob object could not be encoded or decoded.
45    #[error("blob codec failed: {0}")]
46    Codec(String),
47    /// Configured chunks were outside the supported range.
48    #[error("chunk size must be between 64 KiB and 8 MiB, got {0}")]
49    InvalidChunkSize(usize),
50    /// Platform or manifest bounds cannot represent this blob.
51    #[error("blob is too large")]
52    BlobTooLarge,
53    /// Reading a plaintext import stream failed.
54    #[error("blob import stream failed: {0}")]
55    Read(String),
56    /// The operating-system cryptographic random source failed.
57    #[error("cryptographic randomness is unavailable")]
58    RandomnessUnavailable,
59    /// A remote stream was opened without any usable provider.
60    #[error("no blob providers are available")]
61    NoProviders,
62    /// The configured process-wide remote object concurrency was zero.
63    #[error("remote blob concurrency must be non-zero, got {0}")]
64    InvalidFetchConcurrency(usize),
65    /// The in-process fetch scheduler could not admit work safely.
66    #[error("remote blob scheduler is unavailable")]
67    SchedulerUnavailable,
68    /// A coalesced remote fetch owner was cancelled before completing.
69    #[error("remote blob fetch was cancelled")]
70    FetchCancelled,
71}