pub struct WsClient { /* private fields */ }Expand description
Active worker-side WS session. Cheap to construct, expensive to drop (closes the socket gracefully).
Implementations§
Source§impl WsClient
impl WsClient
Sourcepub fn split(self) -> (WsSender, WsReceiver)
pub fn split(self) -> (WsSender, WsReceiver)
Split the client into a cheap-to-clone WsSender and a
single-owner WsReceiver. Used by the runtime so heartbeat,
log-shipper, and engine-dispatch tasks can all push frames
concurrently while a dedicated task drains the receive side.
Source§impl WsClient
impl WsClient
Sourcepub async fn send(&mut self, frame: &WorkerInbound) -> WsResult<()>
pub async fn send(&mut self, frame: &WorkerInbound) -> WsResult<()>
Send a typed inbound frame as a JSON text frame.
Sourcepub async fn recv(&mut self) -> WsResult<Option<WorkerOutbound>>
pub async fn recv(&mut self) -> WsResult<Option<WorkerOutbound>>
Receive the next typed outbound frame. Returns Ok(None) on
a clean close (no error frame), Err on auth or transport
failures, or Ok(Some(frame)) for normal traffic. Pings and
other control frames are swallowed silently.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WsClient
impl !RefUnwindSafe for WsClient
impl !UnwindSafe for WsClient
impl Send for WsClient
impl Sync for WsClient
impl Unpin for WsClient
impl UnsafeUnpin for WsClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.