pub struct EffectfulServer<A: ApiSpec, Provided = ENil> { /* private fields */ }Expand description
A server builder that tracks which middleware effects have been provided.
The Provided type parameter is a type-level list of effects that have
been discharged via .provide::<E>(). It starts as ENil and grows
with each .provide() call.
The .serve() method requires A: AllProvided<Provided, _>, ensuring
that every Requires<E, _> in the
API type has a corresponding .provide::<E>().
Implementations§
Source§impl<A: ApiSpec> EffectfulServer<A, ENil>
impl<A: ApiSpec> EffectfulServer<A, ENil>
Sourcepub fn new<H: Serves<A>>(handlers: H) -> Self
pub fn new<H: Serves<A>>(handlers: H) -> Self
Create an effectful server from a handler tuple.
The handler tuple must cover every endpoint in the API, just like
Server::new.
Source§impl<A: ApiSpec, P> EffectfulServer<A, P>
impl<A: ApiSpec, P> EffectfulServer<A, P>
Sourcepub fn provide<E: Effect>(self) -> EffectfulServer<A, ECons<E, P>>
pub fn provide<E: Effect>(self) -> EffectfulServer<A, ECons<E, P>>
Sourcepub fn max_body_size(self, max: usize) -> Self
pub fn max_body_size(self, max: usize) -> Self
Set the maximum request body size in bytes.
Sourcepub fn with_state<T: Clone + Send + Sync + 'static>(self, state: T) -> Self
pub fn with_state<T: Clone + Send + Sync + 'static>(self, state: T) -> Self
Add shared state accessible via State<T> extractors.
Sourcepub fn layer<L>(self, layer: L) -> EffectfulLayeredServer<A, P, L::Service>
pub fn layer<L>(self, layer: L) -> EffectfulLayeredServer<A, P, L::Service>
Sourcepub fn ready<Idx>(self) -> Server<A>where
A: AllProvided<P, Idx>,
pub fn ready<Idx>(self) -> Server<A>where
A: AllProvided<P, Idx>,
Finalize the server and convert to a regular Server.
Only compiles if all required effects have been provided.
Sourcepub async fn serve<Idx>(
self,
addr: SocketAddr,
) -> Result<(), Box<dyn Error + Send + Sync>>where
A: AllProvided<P, Idx>,
pub async fn serve<Idx>(
self,
addr: SocketAddr,
) -> Result<(), Box<dyn Error + Send + Sync>>where
A: AllProvided<P, Idx>,
Start serving HTTP requests on the given address.
Only compiles if all required effects have been provided via
.provide::<E>() calls.
Sourcepub async fn serve_with_shutdown<Idx>(
self,
listener: TcpListener,
shutdown: impl Future<Output = ()> + Send,
) -> Result<(), Box<dyn Error + Send + Sync>>where
A: AllProvided<P, Idx>,
pub async fn serve_with_shutdown<Idx>(
self,
listener: TcpListener,
shutdown: impl Future<Output = ()> + Send,
) -> Result<(), Box<dyn Error + Send + Sync>>where
A: AllProvided<P, Idx>,
Start serving with graceful shutdown.
Only compiles if all required effects have been provided.