| Crates.io | tokio-nats |
| lib.rs | tokio-nats |
| version | 0.4.2 |
| created_at | 2019-12-22 22:41:19.672393+00 |
| updated_at | 2025-09-15 11:32:26.673139+00 |
| description | Async-await ready NATS library |
| homepage | |
| repository | https://github.com/sebzim4500/tokio-nats |
| max_upload_size | |
| id | 191619 |
| size | 67,499 |
A client for NATS using
tokio and async-await.
There are still features missing, but it should be ready for use in simple situations.
[dependencies]
tokio-nats = "0.4.2"
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;
}