irontide 1.0.1

A Rust BitTorrent library — ergonomic facade for the irontide crate family
Documentation
//! Unified error type wrapping all per-crate errors.
//!
//! Each facade module also re-exports its crate's `Error` type for
//! fine-grained matching (e.g., `irontide::wire::Error`). This unified
//! type allows catching any torrent error with a single type.

/// Unified error type for the `IronTide` crate family.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// Bencode serialization/deserialization error.
    #[error("bencode: {0}")]
    Bencode(#[from] irontide_bencode::Error),

    /// Core type error (hash parsing, torrent validation, magnet links).
    #[error("core: {0}")]
    Core(#[from] irontide_core::Error),

    /// Wire protocol error (handshake, message encoding).
    #[error("wire: {0}")]
    Wire(#[from] irontide_wire::Error),

    /// Tracker communication error.
    #[error("tracker: {0}")]
    Tracker(#[from] irontide_tracker::Error),

    /// DHT operation error.
    #[error("dht: {0}")]
    Dht(#[from] irontide_dht::Error),

    /// Storage I/O error (pieces, chunks, files).
    #[error("storage: {0}")]
    Storage(#[from] irontide_storage::Error),

    /// Session management error (peers, torrents).
    #[error("session: {0}")]
    Session(#[from] irontide_session::Error),

    /// uTP transport error.
    #[error("utp: {0}")]
    Utp(#[from] irontide_utp::Error),

    /// NAT port mapping error.
    #[error("nat: {0}")]
    Nat(#[from] irontide_nat::Error),

    /// Raw I/O error.
    #[error("io: {0}")]
    Io(#[from] std::io::Error),
}

/// Unified result type for the `IronTide` crate family.
pub type Result<T> = std::result::Result<T, Error>;