pub mod bridge;
pub mod config;
pub mod streams;

pub use bridge::NatsBridge;
pub use config::NatsConfig;

#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("NATS connect failed: {0}")]
    Connect(String),

    #[error("NATS publish failed: {0}")]
    Publish(String),

    #[error("JetStream stream error: {0}")]
    Stream(String),

    #[error("JetStream consumer error: {0}")]
    Consumer(String),

    #[error("Serialization error: {0}")]
    Serialization(String),

    #[error("NATS health check failed: {0}")]
    Health(String),
}

pub type Result<T> = std::result::Result<T, Error>;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn nats_config_defaults() {
        let cfg = NatsConfig::default();
        assert_eq!(cfg.url, "nats://127.0.0.1:4222");
        assert_eq!(cfg.subject_prefix, "provisioning");
        assert_eq!(cfg.max_reconnects, 10);
        assert!(cfg.auth_token.is_none());
    }
}
