7 unstable releases

0.4.1 Oct 7, 2024
0.4.0 Oct 3, 2024
0.3.0 Aug 1, 2023
0.2.1 Oct 25, 2022
0.1.0 Dec 22, 2019

#545 in Asynchronous

Download history 47/week @ 2024-08-20 173/week @ 2024-08-27 7/week @ 2024-09-03 18/week @ 2024-09-10 1/week @ 2024-09-17 122/week @ 2024-09-24 223/week @ 2024-10-01 211/week @ 2024-10-08 68/week @ 2024-10-15 23/week @ 2024-10-22 8/week @ 2024-10-29 83/week @ 2024-11-05 114/week @ 2024-11-12 51/week @ 2024-11-19 72/week @ 2024-11-26 45/week @ 2024-12-03

282 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.1"

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;
}

lib.rs:

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.1"

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(|message| async move {
        println!("Received message {:?}", message);
    }).await;
}

Dependencies

~12–29MB
~616K SLoC