Skip to main content

radicle_artifact_node/
lib.rs

1//! Seeding node for radicle artifacts.
2//!
3//! Owns all blob I/O: the persistent iroh-blobs store, serving blobs to
4//! peers, and fetching/exporting/HTTP downloads against that store. The
5//! long-running daemon ([`node::run`]) listens on a Unix control socket;
6//! the `rad-artifact` CLI (and other `radicle-artifact-client` users)
7//! drive it over that socket. Long-running seeding is owned by [`node`];
8//! the async fetch building blocks live in [`fetch`].
9
10use std::io;
11
12pub mod fetch;
13pub mod iroh;
14pub mod node;
15pub mod seeder;
16
17pub use iroh::EndpointConfig;
18
19/// Errors from seeding and fetching operations.
20#[derive(Debug, thiserror::Error)]
21pub enum Error {
22    /// HTTP fetch failed.
23    #[error("HTTP fetch failed: {0}")]
24    Http(String),
25
26    /// Iroh networking or fetch error.
27    #[error("iroh error: {0}")]
28    Iroh(String),
29
30    /// I/O error.
31    #[error("I/O error: {0}")]
32    Io(#[from] io::Error),
33
34    /// Downloaded content does not match expected CID.
35    #[error("CID mismatch: expected {expected}, got {actual}")]
36    CidMismatch {
37        /// The CID that was expected.
38        expected: String,
39        /// The CID that was computed from the actual content.
40        actual: String,
41    },
42
43    /// CID parsing or validation error.
44    #[error("CID error: {0}")]
45    Cid(String),
46}
47
48impl From<radicle_artifact_core::Error> for Error {
49    fn from(e: radicle_artifact_core::Error) -> Self {
50        use radicle_artifact_core::Error as Core;
51        match e {
52            Core::Io(e) => Error::Io(e),
53            Core::Cid(s) => Error::Cid(s),
54            Core::CidMismatch { expected, actual } => Error::CidMismatch { expected, actual },
55            Core::Key(s) => Error::Iroh(s),
56        }
57    }
58}