pub struct ExtensionSender { /* private fields */ }server only.Expand description
Queues server-to-client messages of one connection’s extensions.
The driver writes them in the order they were queued, interleaved
with Responses and StateChanges in no set order (the drafts guarantee
none: “No ordering relationship is guaranteed between ephemeral event
frames and Response or StateChange frames”,
draft-atwood-jmap-chat-wss-00 §Ephemeral Chat Events). The queue is
bounded by ConnectionConfig::extension_queue_capacity.
Clone it freely, for example into a task that forwards events from a
broadcast channel. Once the connection ends every send fails with
ExtensionSendError::Closed, and closed
resolves, so such a task can stop; messages still queued then are
dropped.
Implementations§
Source§impl ExtensionSender
impl ExtensionSender
Sourcepub async fn send<T: Serialize + ?Sized>(
&self,
message: &T,
) -> Result<(), ExtensionSendError>
pub async fn send<T: Serialize + ?Sized>( &self, message: &T, ) -> Result<(), ExtensionSendError>
Queue message, waiting while the queue is full.
Awaiting it in ExtensionHandler::handle cannot deadlock (the
driver keeps writing while handle runs), but with a full queue
handle, and so the next client message, waits on a slow client.
§Errors
ExtensionSendError other than Full.