mirror of
https://github.com/Noratrieb/icefun.git
synced 2026-03-15 16:46:03 +01:00
loop
This commit is contained in:
parent
0b89e245d9
commit
e1ebd97c91
73 changed files with 3822 additions and 3822 deletions
|
|
@ -13,24 +13,24 @@ use crate::common::{
|
|||
task::{self, Poll},
|
||||
Pin,
|
||||
};
|
||||
/// Asynchronously accept incoming connections.
|
||||
|
||||
pub trait Accept {
|
||||
/// The connection type that can be accepted.
|
||||
|
||||
type Conn;
|
||||
/// The error type that can occur when accepting a connection.
|
||||
|
||||
type Error;
|
||||
/// Poll to accept the next connection.
|
||||
|
||||
fn poll_accept(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut task::Context<'_>,
|
||||
) -> Poll<Option<Result<Self::Conn, Self::Error>>>;
|
||||
}
|
||||
/// Adapt a `Stream` of incoming connections into an `Accept`.
|
||||
///
|
||||
/// # Optional
|
||||
///
|
||||
/// This function requires enabling the `stream` feature in your
|
||||
/// `Cargo.toml`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[cfg(feature = "stream")]
|
||||
pub fn from_stream<S, IO, E>(stream: S) -> impl Accept<Conn = IO, Error = E>
|
||||
where
|
||||
|
|
|
|||
|
|
@ -65,29 +65,29 @@ cfg_feature! {
|
|||
}
|
||||
#[cfg(feature = "tcp")]
|
||||
pub use super::tcp::{AddrIncoming, AddrStream};
|
||||
/// A lower-level configuration of the HTTP protocol.
|
||||
///
|
||||
/// This structure is used to configure options for an HTTP server connection.
|
||||
///
|
||||
/// If you don't have need to manage connections yourself, consider using the
|
||||
/// higher-level [Server](super) API.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
|
||||
pub(crate) struct Http<E = Exec> {
|
||||
pub(crate) exec: E,
|
||||
}
|
||||
/// The internal mode of HTTP protocol which indicates the behavior when a parse error occurs.
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
enum ConnectionMode {
|
||||
/// Always use HTTP/1 and do not upgrade when a parse error occurs.
|
||||
|
||||
#[cfg(feature = "http1")]
|
||||
H1Only,
|
||||
/// Always use HTTP/2.
|
||||
|
||||
#[cfg(feature = "http2")]
|
||||
H2Only,
|
||||
/// Use HTTP/1 and try to upgrade to h2 when a parse error occurs.
|
||||
|
||||
#[cfg(all(feature = "http1", feature = "http2"))]
|
||||
Fallback,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pin_project! {
|
|||
protocol : Http_ < E >,
|
||||
}
|
||||
}
|
||||
/// A builder for a [`Server`](Server).
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
|
||||
pub struct Builder<I, E = Exec> {
|
||||
|
|
@ -38,7 +38,7 @@ pub struct Builder<I, E = Exec> {
|
|||
}
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
|
||||
impl<I> Server<I, ()> {
|
||||
/// Starts a [`Builder`](Builder) with the provided incoming stream.
|
||||
|
||||
pub fn builder(incoming: I) -> Builder<I> {
|
||||
loop {}
|
||||
}
|
||||
|
|
@ -49,12 +49,12 @@ impl<I> Server<I, ()> {
|
|||
doc(cfg(all(feature = "tcp", any(feature = "http1", feature = "http2"))))
|
||||
)]
|
||||
impl Server<AddrIncoming, ()> {
|
||||
/// Binds to the provided address, and returns a [`Builder`](Builder).
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This method will panic if binding to the address fails. For a method
|
||||
/// to bind to an address and return a `Result`, see `Server::try_bind`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pub fn bind() -> Builder<AddrIncoming> {
|
||||
loop {}
|
||||
}
|
||||
|
|
@ -71,42 +71,42 @@ where
|
|||
B::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||||
E: ConnStreamExec<<S::Service as HttpService<Body>>::Future, B>,
|
||||
{
|
||||
/// Prepares a server to handle graceful shutdown when the provided future
|
||||
/// completes.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// # fn main() {}
|
||||
/// # #[cfg(feature = "tcp")]
|
||||
/// # async fn run() {
|
||||
/// # use hyper::{Body, Response, Server, Error};
|
||||
/// # use hyper::service::{make_service_fn, service_fn};
|
||||
/// # let make_service = make_service_fn(|_| async {
|
||||
/// # Ok::<_, Error>(service_fn(|_req| async {
|
||||
/// # Ok::<_, Error>(Response::new(Body::from("Hello World")))
|
||||
/// # }))
|
||||
/// # });
|
||||
/// // Make a server from the previous examples...
|
||||
/// let server = Server::bind(&([127, 0, 0, 1], 3000).into())
|
||||
/// .serve(make_service);
|
||||
///
|
||||
/// // Prepare some signal for when the server should start shutting down...
|
||||
/// let (tx, rx) = tokio::sync::oneshot::channel::<()>();
|
||||
/// let graceful = server
|
||||
/// .with_graceful_shutdown(async {
|
||||
/// rx.await.ok();
|
||||
/// });
|
||||
///
|
||||
/// // Await the `server` receiving the signal...
|
||||
/// if let Err(e) = graceful.await {
|
||||
/// eprintln!("server error: {}", e);
|
||||
/// }
|
||||
///
|
||||
/// // And later, trigger the signal by calling `tx.send(())`.
|
||||
/// let _ = tx.send(());
|
||||
/// # }
|
||||
/// ```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fn poll_next_(
|
||||
self: Pin<&mut Self>,
|
||||
|
|
@ -148,7 +148,7 @@ impl<I, E> Builder<I, E> {
|
|||
loop {}
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
pub fn serve<S, B>(self, _: S) -> Server<I, S>
|
||||
where
|
||||
I: Accept,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ impl TcpKeepaliveConfig {
|
|||
loop {}
|
||||
}
|
||||
}
|
||||
/// A stream of connections from binding to an address.
|
||||
|
||||
#[must_use = "streams do nothing unless polled"]
|
||||
pub struct AddrIncoming {
|
||||
addr: SocketAddr,
|
||||
|
|
@ -63,15 +63,15 @@ pub struct AddrIncoming {
|
|||
timeout: Option<Pin<Box<Sleep>>>,
|
||||
}
|
||||
impl AddrIncoming {
|
||||
/// Creates a new `AddrIncoming` binding to provided socket address.
|
||||
|
||||
pub fn bind(addr: &SocketAddr) -> crate::Result<Self> {
|
||||
loop {}
|
||||
}
|
||||
/// Get the local address bound to this listener.
|
||||
|
||||
pub fn local_addr(&self) -> SocketAddr {
|
||||
loop {}
|
||||
}
|
||||
/// Set the value of `TCP_NODELAY` option for accepted connections.
|
||||
|
||||
pub fn set_nodelay(&mut self, enabled: bool) -> &mut Self {
|
||||
loop {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue