pub struct Handle { /* private fields */ }client only.Expand description
A handle to the client service.
This is cheap to clone and can be moved freely between tasks.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn format(&self) -> Format
pub fn format(&self) -> Format
The Format currently in effect for message bodies.
Before the connection has been opened this is the format which was
requested through ServiceBuilder::format. Once the connection is
open it is the format the server actually agreed to, which can differ if
the server does not support what was asked for.
Sourcepub fn on_state_change(&self) -> StateListener
pub fn on_state_change(&self) -> StateListener
Listen for state changes to the underlying connection.
This indicates when the connection is open and ready to receive requests
through State::Open, or if it’s closed and requests will be rejected
through State::Closed.
Sourcepub async fn wait_until_open(&self) -> Result<(), Error>
pub async fn wait_until_open(&self) -> Result<(), Error>
Wait until the connection is open.
Since a connection is established asynchronously, this must be called
before performing the first request unless you are prepared to handle
the Error::is_not_connected error.
This errors if the Service driving the connection is gone, since the
connection can then never be established.
Sourcepub async fn channel(&self) -> Result<Channel, Error>
pub async fn channel(&self) -> Result<Channel, Error>
Open a new logical channel to the websocket server.
A channel can be uniquely identified on the client and server side over
a single connection. This means that if you send a request over a
channel using Channel::request, the server can access the
ChannelId to determine which channel sent the request and the client
has the ability to correlate any responses sent by the server by
inspecting Packet::channel or RawPacket::channel.
The maximum number of channels is implementation defined, but expect it
to be relatively low like 65535 (non-zero 16 bits) to reduce payload
sizes. Failure to allocate a channel is an error.
Note that a channel is scoped to the connection it was opened over. If the connection is lost and re-established, any channel opened over the old connection is stale and has to be opened again.
Sourcepub fn request(&self) -> RequestBuilder<'_, EmptyBody>
pub fn request(&self) -> RequestBuilder<'_, EmptyBody>
Send a request over the default channel.
See RequestBuilder::send for how the request is completed.
Sourcepub fn on_broadcast<T>(&self) -> Listener<T>where
T: Broadcast,
pub fn on_broadcast<T>(&self) -> Listener<T>where
T: Broadcast,
Listen for broadcasts of type T.
Broadcasts are buffered in the returned listener until they are received
with Listener::recv. Dropping the listener removes it.
Note that the buffer is unbounded, so a listener which is not drained
keeps accumulating broadcasts. Drop or clear a listener which is no
longer of interest.
Sourcepub fn close(&self)
pub fn close(&self)
Close the service.
This causes Service::run to return.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handle
impl RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl UnsafeUnpin for Handle
impl UnwindSafe for Handle
Blanket Implementations§
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> HasAllProps<(), T> for T
impl<T> HasAllProps<(), T> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.