pub struct Client { /* private fields */ }Available on crate feature
blocking only.Expand description
The blocking client. Cheap to clone; dropping the last clone the user holds disconnects
(bounded, as Client::disconnect) and stops the runtime. The clients handed to handlers
are for the duration of the call; do not keep them after the last user handle is gone.
Implementations§
Source§impl Client
impl Client
Sourcepub fn emit(
&self,
event: impl AsRef<str>,
data: impl Into<Payload>,
) -> Result<()>
pub fn emit( &self, event: impl AsRef<str>, data: impl Into<Payload>, ) -> Result<()>
See crate::Client::emit (never blocks).
Sourcepub fn emit_with_ack(
&self,
event: impl AsRef<str>,
data: impl Into<Payload>,
timeout: Duration,
) -> Result<Payload>
pub fn emit_with_ack( &self, event: impl AsRef<str>, data: impl Into<Payload>, timeout: Duration, ) -> Result<Payload>
See crate::Client::emit_with_ack; blocks until the ack, the timeout or the loss.
Sourcepub fn disconnect(&self) -> Result<()>
pub fn disconnect(&self) -> Result<()>
See crate::Client::disconnect; blocks (bounded).
Sourcepub fn reconnect(&self) -> Result<()>
pub fn reconnect(&self) -> Result<()>
See crate::Client::reconnect; blocks until the attempt ends.
Sourcepub fn on<F>(&self, event: impl Into<String>, handler: F) -> ListenerId
pub fn on<F>(&self, event: impl Into<String>, handler: F) -> ListenerId
Adds a handler for event.
Sourcepub fn once<F>(&self, event: impl Into<String>, handler: F) -> ListenerId
pub fn once<F>(&self, event: impl Into<String>, handler: F) -> ListenerId
Adds a handler for the next event.
Sourcepub fn off_listener(&self, id: ListenerId) -> bool
pub fn off_listener(&self, id: ListenerId) -> bool
Removes one handler.
Sourcepub fn listener_count(&self, event: &str) -> usize
pub fn listener_count(&self, event: &str) -> usize
Number of handlers of event.
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
The current state.
Sourcepub fn wait_for(
&self,
predicate: impl Fn(&ConnectionState) -> bool,
timeout: Duration,
) -> ConnectionState
pub fn wait_for( &self, predicate: impl Fn(&ConnectionState) -> bool, timeout: Duration, ) -> ConnectionState
Blocks until the state matches predicate, the client closed, or timeout passed;
returns the state then.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Forget for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more