Struct stan::Client[][src]

pub struct Client { /* fields omitted */ }

NATS Streaming client

Implementations

impl Client[src]

pub fn start(
    nats_connection: Connection,
    cluster_id: &str,
    client_id: &str
) -> Result<Client>
[src]

Start a new client, establishing a new NATS Streaming connection, Same as stan::connect().

Example:

    let nats_url = "nats://127.0.0.1:4222";
    let nc = nats::connect(nats_url)?;
    let sc = stan::Client::start(nc, "test-cluster", "rust-client-1")?;

pub fn publish(&self, subject: &str, msg: impl AsRef<[u8]>) -> Result<()>[src]

Publish to a given subject. Will return an error if failed to receive a ack back from the streaming server.

Example:

 fn main() -> io::Result<()> {
    let nats_url = "nats://127.0.0.1:4222";
    let nc = nats::connect(nats_url)?;
    sc.publish("foo", "hello from rust 1")

pub fn subscribe(
    &self,
    subject: &str,
    config: SubscriptionConfig<'_>
) -> Result<Subscription>
[src]

Start a subscription.

Example:

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

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

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

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

Trait Implementations

impl Clone for Client[src]

impl Debug for Client[src]

Auto Trait Implementations

impl !RefUnwindSafe for Client

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl !UnwindSafe for Client

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,