ruststream-nats 0.6.0

NATS / JetStream broker implementation for the RustStream messaging framework.
Documentation
//! Error type returned by NATS broker operations.

use std::error::Error as StdError;

use thiserror::Error;

/// Errors surfaced by the NATS broker implementation.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum NatsError {
    /// Failed to establish or use the underlying `async-nats` connection.
    #[error("nats connection error: {0}")]
    Connect(#[source] Box<dyn StdError + Send + Sync>),

    /// Failed to publish a message to the broker.
    #[error("nats publish error: {0}")]
    Publish(#[source] Box<dyn StdError + Send + Sync>),

    /// Failed to subscribe to the requested subject.
    #[error("nats subscribe error: {0}")]
    Subscribe(#[source] Box<dyn StdError + Send + Sync>),

    /// JetStream-specific operation failed (consumer creation, publish acknowledgement, ack).
    #[error("nats jetstream error: {0}")]
    JetStream(#[source] Box<dyn StdError + Send + Sync>),

    /// Draining the connection during
    /// [`shutdown`](ruststream::ConnectedBroker::shutdown) failed.
    #[error("nats shutdown error: {0}")]
    Shutdown(#[source] Box<dyn StdError + Send + Sync>),

    /// A request / reply operation timed out before a reply was received.
    #[error("nats request timed out")]
    RequestTimeout,

    /// A publisher aliasing the connection was used after the broker shut down.
    ///
    /// The lifecycle ladder makes misuse through the owner's handle a compile error:
    /// [`ConnectedBroker::shutdown`](ruststream::ConnectedBroker::shutdown) consumes the connected
    /// broker. Publishers paired off it earlier keep aliasing the closed connection, so their
    /// operations report this instead of silently succeeding against a dead connection.
    #[error("nats connection is closed; cannot reach {subject}")]
    Closed {
        /// The subject the closed publisher was asked to reach.
        subject: String,
    },

    /// The supplied [`crate::SubscribeOptions`] combine fields in a way the broker cannot honour
    /// (for example `durable(_)` without `jetstream(_)`, or `queue_group(_)` together with
    /// `jetstream(_)`).
    #[error("invalid subscribe options: {0}")]
    InvalidOptions(String),
}