Struct kernel::registry::listener::RequestStream
source · pub struct RequestStream<D: RegisteredDriver> {
chan: KConsumer<Message<D>>,
listener: Listener<D>,
}Expand description
A stream of incoming requests from all clients.
This type is used when a service wishes all clients to send requests to the same channel. It automatically accepts all incoming connections with the same request channel, and returns any received requests to the service.
A Listener can be converted into a RequestStream using the
Listener::into_request_stream method.
Any Hello messages received from new connections are discarded by the
RequestStream, and connections are never rejected with a
ConnectError.
Note, however, that this type does not require that the
RegisteredDriver type’s RegisteredDriver::Hello type is [()], or
that its RegisteredDriver::ConnectError type is
core::convert::Infallible. This is because a RegisteredDriver
declaration which includes a Hello and/or ConnectError type may be
implemented by a server that does not care about Hellos or about
rejecting connections on some platforms. Other platforms may
implement the same RegisteredDriver declaration with a service that does
consume Hellos or reject connections, but RequestStream is still
usable with that RegisteredDriver in cases where the implementation does
not need those features.
Fields§
§chan: KConsumer<Message<D>>§listener: Listener<D>Implementations§
source§impl<D: RegisteredDriver> RequestStream<D>
impl<D: RegisteredDriver> RequestStream<D>
sourcepub async fn next_request(&self) -> Message<D>
pub async fn next_request(&self) -> Message<D>
Returns the next incoming message, accepting any new connections until a message is received.
If all request senders have been dropped, this method waits until a new connection is available to accept, and then waits for a message from a client.
Note: Any Hello messages received from new connections are
discarded.