Skip to main content

WsReader

Struct WsReader 

Source
pub struct WsReader { /* private fields */ }
Expand description

The read half of a WebSocket (from split). Owns the receive path; can block in recv on its own thread while a WsWriter sends. Incoming pings are still auto-ponged (via the shared, write-serialized transport) and a peer close is echoed.

Implementations§

Source§

impl WsReader

Source

pub fn set_auto_pong(&mut self, on: bool)

Enable/disable automatic PONG replies to pings (curl’s CURLWS_NOAUTOPONG). Affects recv_event only; recv always auto-pongs.

Source

pub fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()>

Set the per-read inactivity timeout. None blocks indefinitely.

Source

pub fn shutdown_handle(&self) -> Option<WsShutdown>

A handle to force-close the socket from another thread, unblocking this reader if it’s parked in recv. See WsShutdown.

Source

pub fn is_closed(&self) -> bool

Whether the connection is closed or closing (either half).

Source

pub fn recv(&mut self) -> Result<Option<WsMessage>>

Block until the next data message arrives, auto-answering interleaved control frames. Ok(None) once the peer closes.

Source

pub fn recv_event(&mut self) -> Result<WsEvent>

Receive the next WsEvent, surfacing control frames. A ping is auto-ponged (through the shared, write-serialized transport) unless auto-pong is off; a close is echoed.

Source

pub fn recv_frame(&mut self) -> Result<WsFrame>

Receive a single raw frame (no reassembly/decompression/control handling) — curl’s raw mode.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.