pub struct HyperConnections { /* private fields */ }Expand description
Accepts at one address and serves each connection with one service.
This is all a framework needs to be served when it exposes a service rather than an accept loop. The listener stays here, so closing drops it and frees the address immediately, while connections already accepted are given the drain to finish.
Implementations§
Source§impl HyperConnections
impl HyperConnections
Sourcepub fn serve<Answering, ResponseBody>(
listener: TcpListener,
service: Answering,
drain: Duration,
) -> Self
pub fn serve<Answering, ResponseBody>( listener: TcpListener, service: Answering, drain: Duration, ) -> Self
Serves every connection accepted at listener with service, draining for drain.
The drain is stated here rather than fixed, because how long a request may take is what the
surface being served decides, not what accepting it does. DRAIN is the usual answer.
Sourcepub async fn close(&mut self)
pub async fn close(&mut self)
Releases the address, leaving what is already being served to finish on its own.
Aborting the accept task drops the listener, which is what frees the address, and awaiting
the handle is what makes it free on return rather than shortly after. Each connection is
then told to shut down gracefully, which is what makes one finish: it answers what it is
producing and then ends, rather than waiting for a request no caller will send. This does
not wait for that, which is what Self::end is for.
Sourcepub async fn end(&mut self)
pub async fn end(&mut self)
Releases the address, then gives what is already being served up to the drain to finish.
Whatever is still serving when the drain runs out is ended, so this resolves within the
drain of Self::close however slow a request is.
Trait Implementations§
Source§impl Drop for HyperConnections
impl Drop for HyperConnections
Auto Trait Implementations§
impl !RefUnwindSafe for HyperConnections
impl !Send for HyperConnections
impl !Sync for HyperConnections
impl !UnwindSafe for HyperConnections
impl Freeze for HyperConnections
impl Unpin for HyperConnections
impl UnsafeUnpin for HyperConnections
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<This> HttpProgramExt<This> for This
impl<This> HttpProgramExt<This> for This
Source§fn compile_http<Program>(
&self,
program: Program,
) -> <Program as HttpProgramAlg<This>>::Routewhere
Program: HttpProgramAlg<This>,
fn compile_http<Program>(
&self,
program: Program,
) -> <Program as HttpProgramAlg<This>>::Routewhere
Program: HttpProgramAlg<This>,
Compiles a named HTTP program with this interpreter.