mirror of
https://github.com/Noratrieb/icefun.git
synced 2026-03-15 08:36:04 +01:00
loop
This commit is contained in:
parent
a434a3de71
commit
270f547952
5 changed files with 69 additions and 582 deletions
|
|
@ -5,32 +5,26 @@
|
|||
//! - The [`Accept`](Accept) trait used to asynchronously accept incoming
|
||||
//! connections.
|
||||
//! - Utilities like `poll_fn` to ease creating a custom `Accept`.
|
||||
#[cfg(feature = "stream")]
|
||||
use futures_core::Stream;
|
||||
#[cfg(feature = "stream")]
|
||||
use pin_project_lite::pin_project;
|
||||
use crate::common::{
|
||||
task::{self, Poll},
|
||||
Pin,
|
||||
};
|
||||
#[cfg(feature = "stream")]
|
||||
use futures_core::Stream;
|
||||
#[cfg(feature = "stream")]
|
||||
use pin_project_lite::pin_project;
|
||||
|
||||
pub trait Accept {
|
||||
|
||||
type Conn;
|
||||
|
||||
|
||||
type Error;
|
||||
|
||||
|
||||
fn poll_accept(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut task::Context<'_>,
|
||||
) -> Poll<Option<Result<Self::Conn, Self::Error>>>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[cfg(feature = "stream")]
|
||||
pub fn from_stream<S, IO, E>(stream: S) -> impl Accept<Conn = IO, Error = E>
|
||||
where
|
||||
|
|
@ -49,7 +43,7 @@ where
|
|||
self: Pin<&mut Self>,
|
||||
cx: &mut task::Context<'_>,
|
||||
) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
|
||||
self.project().stream.poll_next(cx)
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
FromStream { stream }
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ impl Server<AddrIncoming, ()> {
|
|||
}
|
||||
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
|
||||
impl<I, IO, IE, S, B, E> Future for Server<I, S, E>
|
||||
impl<I, IO, IE, S, E> Future for Server<I, S, E>
|
||||
where
|
||||
I: Accept<Conn = IO, Error = IE>,
|
||||
IE: Into<Box<dyn StdError + Send + Sync>>,
|
||||
S: MakeServiceRef<IO, Body, ResBody = B>,
|
||||
S: MakeServiceRef<IO, Body>,
|
||||
E: NewSvcExec<IO, S::Future, S::Service, E, NoopWatcher>,
|
||||
{
|
||||
type Output = ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue