NATS Streaming (STAN) is a layer on top of NATS that adds at-least-once delivery. The official nats.rs client doesn’t support NATS Streaming, so I wrote stan, a small crate that wraps nats.rs and handles the NATS Streaming protocol. It’s published on crates.io as stan.

It supports:

  • Publishing messages
  • Subscribing with a handler, or iterating over messages (with an optional timeout)
  • Queue groups and durable subscriptions
  • Choosing where a subscription starts, e.g. all available messages
  • Manual acks
let nc = nats::connect(nats_url)?;
let sc = stan::connect(nc, "test-cluster", "rust-client-1")?;

sc.publish("foo", "hello from rust 1")?;

Source on GitHub: ReifyAB/stan-rs