pub struct Connection<H, P = NoPush> { /* private fields */ }server only.Expand description
One JMAP-over-WebSocket connection: a RequestHandler, a
PushSource and limits. See the module docs.
Implementations§
Source§impl<H: RequestHandler> Connection<H, NoPush>
impl<H: RequestHandler> Connection<H, NoPush>
Sourcepub fn new(handler: Arc<H>) -> Self
pub fn new(handler: Arc<H>) -> Self
A connection answering with handler, with no push
(NoPush) and the default ConnectionConfig.
Source§impl<H: RequestHandler, P: PushSource> Connection<H, P>
impl<H: RequestHandler, P: PushSource> Connection<H, P>
Sourcepub fn with_push<Q: PushSource>(self, push: Q) -> Connection<H, Q>
pub fn with_push<Q: PushSource>(self, push: Q) -> Connection<H, Q>
Push notifications from push.
Sourcepub fn with_config(self, config: ConnectionConfig) -> Self
pub fn with_config(self, config: ConnectionConfig) -> Self
Use config.
Also hold a permit of limit while each Request runs, failing the
Request with maxConcurrentRequests when none is free. Share one
semaphore with the HTTP API endpoint to apply the limit to “the sum
of requests made on both” (RFC 8887 §4.3.2).
Sourcepub fn with_extension<X: ExtensionHandler>(self, handler: X) -> Self
pub fn with_extension<X: ExtensionHandler>(self, handler: X) -> Self
Route client messages of handler’s
message_types to handler
instead of answering them with notRequest. Call it once per
extension capability the Session advertises; see
ExtensionHandler for the order of calls.
§Panics
If one of the types is an RFC 8887 type (Request,
WebSocketPushEnable, WebSocketPushDisable, Response,
RequestError, StateChange) or was registered by an earlier
handler: both are programming errors.
Sourcepub fn close_handle(&self) -> CloseHandle
pub fn close_handle(&self) -> CloseHandle
A handle that closes this connection while it runs, with a Close
frame code and reason of the deployment’s choosing (for expired
credentials, RFC 8887 §4.2). Take it before calling
run; see CloseHandle for what closing does.
Sourcepub async fn run<S, K, E>(
self,
incoming: S,
outgoing: K,
) -> Result<(), ConnectionError>
pub async fn run<S, K, E>( self, incoming: S, outgoing: K, ) -> Result<(), ConnectionError>
Serve the connection until the client closes it, the incoming stream ends, or the deployment closes it.
Returns Ok after a Close, the end of incoming, a binary
message under BinaryFrames::Close (after sending the Close), or
a CloseHandle::close (after sending its Close).
Requests still running then are dropped; method calls the
Dispatcher already started still finish (see
Dispatcher::dispatch, Cancellation). Before returning, by any
path, it closes the extension message queue, waits for an
ExtensionHandler::handle that is running, and calls every
ExtensionHandler::close.
§Errors
ConnectionError if incoming or outgoing fails, or a message
does not serialize.