Struct stan::Client [−][src]
NATS Streaming client
Implementations
impl Client
[src]
pub fn start(
nats_connection: Connection,
cluster_id: &str,
client_id: &str
) -> Result<Client>
[src]
nats_connection: Connection,
cluster_id: &str,
client_id: &str
) -> Result<Client>
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]
&self,
subject: &str,
config: SubscriptionConfig<'_>
) -> Result<Subscription>
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,