Crate stan[][src]

NATS Streaming client wrapper built on top of NATS.rs

Just a very early prototype.

Supports publishing and basic subscription.

Examples

use nats;
use std::{io, str::from_utf8};

fn main() -> io::Result<()> {
    let nc = nats::connect("nats://127.0.0.1:4222")?;
    let sc = stan::connect(nc, "test-cluster", "rust-client-1")?;

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

    let sub1 = sc
        .subscribe("foo", Default::default())?
        .with_handler(|msg| {
            println!("sub1 got {:?}", from_utf8(msg.data));
            msg.ack()?;
            println!("manually acked!");
            Ok(())
        });

    sc.subscribe("foo", Default::default())?
        .with_handler(|msg| {
            println!("sub 2 got {:?}", from_utf8(msg.data));
            Ok(())
        });

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

    sub1.unsubscribe()?;

    sc.publish("foo", "hello from rust 4")?;
    Ok(())
}

Structs

Client
Message
Subscription
SubscriptionConfig

Enums

SubscriptionStart

Functions

connect