pub struct WsSender { /* private fields */ }Expand description
Owning send-half of a WebSocket connection (bd:JMAP-6r7c.31).
Returned from WsSession::split. Holds the underlying tungstenite
sink and exposes the per-direction send methods that the unified
WsSession previously bundled with the receive half. Use with
WsReceiver in two-task topologies (one task in a next_frame loop,
one task occasionally sending requests) — the previous unified shape
required serialising send and receive through a single &mut WsSession
borrow, which made concurrent send-while-receiving impossible without a
Mutex that holds across .await.
Implementations§
Source§impl WsSender
impl WsSender
Sourcepub async fn send_text(&mut self, text: String) -> Result<(), ClientError>
pub async fn send_text(&mut self, text: String) -> Result<(), ClientError>
Send a raw text frame over the WebSocket connection.
Used by extension crates to send non-JMAP frames (e.g., JMAP Chat ephemeral stream control messages).
Sourcepub async fn send_request(
&mut self,
req: &JmapRequest,
id: Option<&str>,
) -> Result<(), ClientError>
pub async fn send_request( &mut self, req: &JmapRequest, id: Option<&str>, ) -> Result<(), ClientError>
Send a JMAP request over the WebSocket connection.
Serializes req and injects "@type": "Request" into the outgoing
JSON object as required by RFC 8887 §4.3.2. The optional id is
echoed back in the corresponding Response frame, enabling out-of-order
correlation.
§Errors
Returns ClientError::Serialize if req cannot be serialized, or
ClientError::WebSocket on a transport failure.