pub struct Listener<D: RegisteredDriver> {
rx: KConsumer<Handshake<D>>,
}Expand description
A listener for incoming connection Handshakes to a RegisteredDriver.
Fields§
§rx: KConsumer<Handshake<D>>Implementations§
source§impl<D: RegisteredDriver> Listener<D>
impl<D: RegisteredDriver> Listener<D>
sourcepub async fn new(incoming_capacity: usize) -> (Self, Registration<D>)
pub async fn new(incoming_capacity: usize) -> (Self, Registration<D>)
Returns a new Listener and an associated Registration.
The Listener’s channel will have capacity for up to
incoming_capacity un-accepted connections before clients have to wait
to send a connection.
sourcepub async fn handshake(&self) -> Handshake<D>
pub async fn handshake(&self) -> Handshake<D>
Awaits the next incoming Handshake to this listener.
This method returns a Handshake when a new incoming connection
request is received. If no incoming connection is available, this method
will yield until one is ready.
To return an incoming connection if one is available, without waiting,
use the try_handshake method.
sourcepub async fn try_handshake(&self) -> Option<Handshake<D>>
pub async fn try_handshake(&self) -> Option<Handshake<D>>
sourcepub async fn into_request_stream(self, capacity: usize) -> RequestStream<D>
pub async fn into_request_stream(self, capacity: usize) -> RequestStream<D>
Converts this Listener into a RequestStream — a simple stream of
incoming requests, which accepts all connections
with the same KChannel.
The next request from any client may be awaited from the
RequestStream using the RequestStream::next_request method.
This is useful when a service wishes to handle all requests with the
same channel, rather than spawning separate worker tasks for each
client, or routing requests based on a connection’s Hello message.
Note: Any Hello messages received from new connections are
discarded by the RequestStream.