Skip to main content

HttpServerAlg

Trait HttpServerAlg 

Source
pub trait HttpServerAlg {
    type Program;
    type Open;
    type Error;

    // Required methods
    fn open(
        &mut self,
        setup: HttpServerSetup<Self::Program>,
    ) -> impl Future<Output = Result<Self::Open, Self::Error>>;
    fn close(
        &mut self,
        open: &mut Self::Open,
    ) -> impl Future<Output = Result<(), Self::Error>>;
    fn end(
        &mut self,
        open: &mut Self::Open,
    ) -> impl Future<Output = Result<(), Self::Error>>;
}
Expand description

Interprets the lifecycle of one bound HTTP surface.

Required Associated Types§

Source

type Program

Carries the executable HTTP surface this server serves.

Source

type Open

Carries a concrete open server.

Source

type Error

States a failure while opening or closing a server.

Required Methods§

Source

fn open( &mut self, setup: HttpServerSetup<Self::Program>, ) -> impl Future<Output = Result<Self::Open, Self::Error>>

Opens the address a setup names and resolves only once it is ready to serve.

Must leave no address bound if dropped before it resolves, so a call still binding can be cancelled.

Source

fn close( &mut self, open: &mut Self::Open, ) -> impl Future<Output = Result<(), Self::Error>>

Closes an open server and resolves only once its address is released.

Nothing already being served is waited for. Those requests are answered, or ended when this interpretation’s drain runs out, which may happen after this has resolved. So closing is what a caller wants to take the address back, and Self::end is what it wants to know the server is done.

Leaves open available when closing fails, so a manager can retain the state it still owns rather than pretending the server disappeared.

Source

fn end( &mut self, open: &mut Self::Open, ) -> impl Future<Output = Result<(), Self::Error>>

Closes an open server and resolves once nothing it accepted is still being served either.

A request already being served is answered, and one still being served when this interpretation’s drain runs out is ended. So ending neither abandons whoever is mid-request nor waits on them without a bound.

An interpretation that cannot tell the two apart resolves this where Self::close resolves, which satisfies both: the address is released and the drain is over.

Leaves open available when ending fails, for the reason Self::close does.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§