Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(server): polish server connection docs #3325

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/server/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ type Http1Dispatcher<T, B, S> = proto::h1::Dispatcher<
>;

pin_project_lite::pin_project! {
/// A future binding an http1 connection with a Service.
/// A [`Future`](core::future::Future) representing an HTTP/1 connection, bound to a
/// [`Service`](crate::service::Service), returned from
/// [`Builder::serve_connection`](struct.Builder.html#method.serve_connection).
///
/// Polling this future will drive HTTP forward.
/// To drive HTTP on this connection this future **must be polled**, typically with
/// `.await`. If it isn't polled, no progress will be made on this connection.
#[must_use = "futures do nothing unless polled"]
pub struct Connection<T, S>
where
Expand Down
7 changes: 5 additions & 2 deletions src/server/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ use crate::service::HttpService;
use crate::{common::time::Time, rt::Timer};

pin_project! {
/// A future binding an HTTP/2 connection with a Service.
/// A [`Future`](core::future::Future) representing an HTTP/2 connection, bound to a
/// [`Service`](crate::service::Service), returned from
/// [`Builder::serve_connection`](struct.Builder.html#method.serve_connection).
///
/// Polling this future will drive HTTP forward.
/// To drive HTTP on this connection this future **must be polled**, typically with
/// `.await`. If it isn't polled, no progress will be made on this connection.
#[must_use = "futures do nothing unless polled"]
pub struct Connection<T, S, E>
where
Expand Down
10 changes: 8 additions & 2 deletions src/server/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
//! are not handled at this level. This module provides the building blocks to
//! customize those things externally.
//!
//! This module is split by HTTP version. Both work similarly, but do have
//! specific options on each builder.
//! This module is split by HTTP version, providing a connection builder for
//! each. They work similarly, but they each have specific options.
//!
//! If your server needs to support both versions, an auto-connection builder is
//! provided in the [`hyper-util`](https://github.com/hyperium/hyper-util/tree/master)
//! crate. This builder wraps the HTTP/1 and HTTP/2 connection builders from this
//! module, allowing you to set configuration for both. The builder will then check
//! the version of the incoming connection and serve it accordingly.
Comment on lines +11 to +15
Copy link
Contributor Author

@oddgrd oddgrd Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should link to the hyper-util crates.io page when it's released. Perhaps we should open an issue for creating an auto-connection example in hyper-util as well?


#[cfg(feature = "http1")]
pub mod http1;
Expand Down
2 changes: 1 addition & 1 deletion src/service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ pub trait Service<Request> {
/// - It's clearer that Services can likely be cloned
/// - To share state across clones you generally need Arc<Mutex<_>>
/// that means you're not really using the &mut self and could do with a &self
/// To see the discussion on this see: https://github.com/hyperium/hyper/issues/3040
/// To see the discussion on this see: <https://github.com/hyperium/hyper/issues/3040>
fn call(&self, req: Request) -> Self::Future;
}
Loading