[−][src]Struct cord_client::Conn
A Conn
is used to connect to and communicate with a broker.
Examples
use cord_client::Conn; use futures::{future, Future}; use tokio; let fut = Conn::new("127.0.0.1:7101".parse().unwrap()).and_then(|mut conn| { // Tell the broker we're going to provide the namespace /users conn.provide("/users".into()).unwrap(); // Start publishing events... conn.event("/users/mark".into(), "Mark has joined").unwrap(); Ok(()) }).map_err(|_| ()); tokio::run(fut);
Methods
impl Conn
[src]
pub fn new(addr: SocketAddr) -> impl Future<Item = Conn, Error = Error>
[src]
Connect to a broker
pub fn forward<S>(self, stream: S) -> impl Future<Item = Self, Error = Error> where
S: Stream<Item = Message, Error = Error>,
[src]
S: Stream<Item = Message, Error = Error>,
If you have a stream that produces Message
s, you can forward that directly to
the inner Sink
instead of calling the helper methods.
pub fn provide(&mut self, namespace: Pattern) -> Result<()>
[src]
Inform the broker that you will be providing a new namespace
pub fn revoke(&mut self, namespace: Pattern) -> Result<()>
[src]
Inform the broker that you will no longer be providing a namespace
pub fn subscribe(&mut self, namespace: Pattern) -> Result<Subscriber>
[src]
Subscribe to another provider's namespace
Examples
conn.subscribe("/users/".into()).unwrap().for_each(|msg| { // Handle the message... dbg!("The following user just joined: {}", msg); Ok(()) })
pub fn unsubscribe(&mut self, namespace: Pattern) -> Result<()>
[src]
Unsubscribe from another provider's namespace
pub fn event<S: Into<String>>(
&mut self,
namespace: Pattern,
data: S
) -> Result<()>
[src]
&mut self,
namespace: Pattern,
data: S
) -> Result<()>
Publish an event to your subscribers
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Conn
impl Send for Conn
impl Sync for Conn
impl Unpin for Conn
impl !UnwindSafe for Conn
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,
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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.
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>,