pub async fn handle_receiver<T, Fut, F>(
receiver_stream: ReceiverRequestStream,
request_stream_handler: F,
) -> Result<(), Error>where
T: ProtocolMarker,
Fut: Future<Output = ()> + Send,
F: Fn(T::RequestStream) -> Fut + Send + Sync + Copy + 'static,
Expand description
Dispatches incoming connections on receiver_stream to
request_stream_handler.
receiver_stream` is a sandbox receiver channel.
Example:
async fn handle_echo_request_stream(mut stream: fecho::EchoRequestStream) { while let Ok(Some(_request)) = stream.try_next().await { // … handle request … } } … task_group.spawn(async move { let _ = realm_proxy::service::handle_receiver::<fecho::EchoMarker, _, _>( echo_receiver_stream, handle_echo_request_stream, ) .await .map_err(|e| { error!(“Failed to serve echo stream: {}”, e); }); });