tokio-nats

Crates.iotokio-nats
lib.rstokio-nats
version0.4.1
sourcesrc
created_at2019-12-22 22:41:19.672393
updated_at2024-10-07 13:36:03.463345
descriptionAsync-await ready NATS library
homepage
repositoryhttps://github.com/sebzim4500/tokio-nats
max_upload_size
id191619
size67,491
Sebastian Zimmer (sebzim4500)

documentation

README

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;
}
Commit count: 27

cargo fmt