pub trait State: 'static {
type Error;
}Expand description
Application state used by web services.
A web::App is parameterized by a type that implements this
trait. The state is available to handlers registered with
Route::to_with_state(), and to filters,
middleware, and services through their service context.
The associated Error type selects the application’s error domain, which
is used by WebError and
WebResponseError. Most applications use
DefaultError.
The trait does not require Clone, but serving an application does:
the server and HttpService clone the state
for each connection.
use ntex::web;
#[derive(Clone)]
struct ApplicationState {
greeting: String,
}
impl web::State for ApplicationState {
type Error = web::DefaultError;
}Required Associated Types§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".