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 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 or the incoming stream ends.
Returns Ok after a Close, the end of incoming, or a binary
message under BinaryFrames::Close (after sending the Close).
Requests still running then are dropped; method calls the
Dispatcher already started still finish (see
Dispatcher::dispatch, Cancellation).
§Errors
ConnectionError if incoming or outgoing fails, or a message
does not serialize.