http_types/upgrade/
receiver.rs
1use futures_lite::Stream;
2
3use std::future::Future;
4use std::pin::Pin;
5use std::task::{Context, Poll};
6
7use crate::upgrade::Connection;
8
9#[must_use = "Futures do nothing unless polled or .awaited"]
11#[derive(Debug)]
12pub struct Receiver {
13 receiver: async_channel::Receiver<Connection>,
14}
15
16impl Receiver {
17 #[allow(unused)]
19 pub(crate) fn new(receiver: async_channel::Receiver<Connection>) -> Self {
20 Self { receiver }
21 }
22}
23
24impl Future for Receiver {
25 type Output = Option<Connection>;
26
27 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
28 Pin::new(&mut self.receiver).poll_next(cx)
29 }
30}