pub trait Channel{
type Req;
type Resp;
// Required methods
fn config(&self) -> &Config;
fn in_flight_requests(self: Pin<&mut Self>) -> usize;
fn start_request(self: Pin<&mut Self>, request_id: u64) -> AbortRegistration;
// Provided methods
fn max_concurrent_requests(self, n: usize) -> Throttler<Self>
where Self: Sized { ... }
fn respond_with<S>(self, server: S) -> ClientHandler<Self, S>
where S: Serve<Self::Req, Resp = Self::Resp>,
Self: Sized { ... }
}
Expand description
The server end of an open connection with a client, streaming in requests from, and sinking responses to, the client.
Channels are free to somewhat rely on the assumption that all in-flight requests are eventually
either cancelled or responded to. Safety cannot
rely on this assumption, but it is best for Channel
users to always account for all outstanding
requests.
Required Associated Types§
Required Methods§
Sourcefn in_flight_requests(self: Pin<&mut Self>) -> usize
fn in_flight_requests(self: Pin<&mut Self>) -> usize
Returns the number of in-flight requests over this channel.
Sourcefn start_request(self: Pin<&mut Self>, request_id: u64) -> AbortRegistration
fn start_request(self: Pin<&mut Self>, request_id: u64) -> AbortRegistration
Tells the Channel that request with ID request_id
is being handled.
The request will be tracked until a response with the same ID is sent
to the Channel.
Provided Methods§
Sourcefn max_concurrent_requests(self, n: usize) -> Throttler<Self>where
Self: Sized,
fn max_concurrent_requests(self, n: usize) -> Throttler<Self>where
Self: Sized,
Caps the number of concurrent requests.
Sourcefn respond_with<S>(self, server: S) -> ClientHandler<Self, S>
fn respond_with<S>(self, server: S) -> ClientHandler<Self, S>
Respond to requests coming over the channel with f
. Returns a future that drives the
responses and resolves when the connection is closed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.