hyperi-rustlib 2.8.6

There's plenty of sage advice out there about how to run Rust services in production at scale — config cascades, structured logging, masking secrets, multi-backend secrets management, Prometheus, OpenTelemetry, Kafka transports, tiered disk-spillover sinks, adaptive worker pools, graceful shutdown — but almost none of it as code you can just install and use. This is that code. Opinionated, drop-in, working out of the box. The patterns from blog posts, watercooler chats and beers with your Google mates as actual library — not a framework you assemble from twenty crates and 8 weeks of munging.
Documentation
// Project:   hyperi-rustlib
// File:      src/transport/error.rs
// Purpose:   Transport error types
// Language:  Rust
//
// License:   BUSL-1.1
// Copyright: (c) 2026 HYPERI PTY LIMITED

use thiserror::Error;

/// Result type for transport operations.
pub type TransportResult<T> = Result<T, TransportError>;

/// Errors that can occur during transport operations.
#[derive(Debug, Error)]
pub enum TransportError {
    /// Configuration error (missing or invalid config).
    #[error("transport config error: {0}")]
    Config(String),

    /// Connection error (network, auth, etc.).
    #[error("transport connection error: {0}")]
    Connection(String),

    /// Send operation failed.
    #[error("transport send error: {0}")]
    Send(String),

    /// Receive operation failed.
    #[error("transport receive error: {0}")]
    Recv(String),

    /// Commit/acknowledge operation failed.
    #[error("transport commit error: {0}")]
    Commit(String),

    /// Transport is closed or shutting down.
    #[error("transport closed")]
    Closed,

    /// Timeout waiting for operation.
    #[error("transport operation timed out")]
    Timeout,

    /// Backpressure - transport cannot accept more messages.
    #[error("transport backpressure")]
    Backpressure,

    /// Internal transport error.
    #[error("transport internal error: {0}")]
    Internal(String),

    /// Admin operation error (topic/partition management).
    #[error("transport admin error: {0}")]
    Admin(String),
}

impl TransportError {
    /// Returns true if this error is recoverable (retry may succeed).
    #[must_use]
    pub fn is_recoverable(&self) -> bool {
        matches!(self, Self::Timeout | Self::Backpressure)
    }

    /// Returns true if this error indicates the transport is unusable.
    #[must_use]
    pub fn is_fatal(&self) -> bool {
        matches!(self, Self::Closed | Self::Config(_))
    }
}