8 releases

0.4.2 Sep 15, 2025
0.4.1 Oct 7, 2024
0.3.0 Aug 1, 2023
0.2.1 Oct 25, 2022
0.1.0 Dec 22, 2019

#870 in Cryptography

Download history 601/week @ 2025-09-11 396/week @ 2025-09-18 138/week @ 2025-09-25 57/week @ 2025-10-02 101/week @ 2025-10-09 82/week @ 2025-10-16 49/week @ 2025-10-23 53/week @ 2025-10-30 27/week @ 2025-11-06 18/week @ 2025-11-13 29/week @ 2025-11-20 56/week @ 2025-11-27 47/week @ 2025-12-04 56/week @ 2025-12-11 6/week @ 2025-12-18

124 downloads per month

LGPL-3.0

33KB
688 lines

Crates.io docs.rs A client for NATS using tokio and async-await. There are still features missing, but it should be ready for use in simple situations.

Installation

[dependencies]
tokio-nats = "0.4.2"

Usage

use tokio_nats::{NatsConfigBuilder, connect};
use futures_util::StreamExt;
async fn demo() {
    let config = NatsConfigBuilder::default()
        .server("127.0.0.1:4222")
        .build()
        .unwrap();
    let mut client = connect(config).await.unwrap();
    client.publish("MySubject", "hello world".as_bytes()).await.unwrap();
    client.subscribe("MyOtherSubject").await.unwrap().for_each(async move |message| {
        println!("Received message {:?}", message);
    }).await;
}

Dependencies

~12–33MB
~651K SLoC