Trait Channel

Source
pub trait Channel
where Self: Transport<Response<Self::Resp>, Request<Self::Req>>,
{ 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§

Source

type Req

Type of request item.

Source

type Resp

Type of response sink item.

Required Methods§

Source

fn config(&self) -> &Config

Configuration of the channel.

Source

fn in_flight_requests(self: Pin<&mut Self>) -> usize

Returns the number of in-flight requests over this channel.

Source

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§

Source

fn max_concurrent_requests(self, n: usize) -> Throttler<Self>
where Self: Sized,

Caps the number of concurrent requests.

Source

fn respond_with<S>(self, server: S) -> ClientHandler<Self, S>
where S: Serve<Self::Req, Resp = Self::Resp>, Self: Sized,

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.

Implementors§

Source§

impl<C> Channel for Throttler<C>
where C: Channel,

Source§

type Req = <C as Channel>::Req

Source§

type Resp = <C as Channel>::Resp

Source§

impl<Req, Resp, T> Channel for BaseChannel<Req, Resp, T>
where T: Transport<Response<Resp>, ClientMessage<Req>>,

Source§

type Req = Req

Source§

type Resp = Resp