#[non_exhaustive]pub struct AppState {
pub config: Config,
pub middlewares: LoadedMiddlewares,
pub tracer: TraceEmitter,
/* private fields */
}Expand description
Shared state, held once and read by reference from each per-request
task via Arc<AppState> — see Server::app_state.
§RFC 071: no Clone, deliberately
Before RFC 071, Server::app_state was a plain AppState behind
Arc<Mutex<_>>, and service() called .lock().await.clone() once
per request — an O(config size) deep clone (rule sets included) on
every request, serialised through the lock. Neither half is needed:
nothing mutates AppState after startup (see the interior-mutability
note on Server::app_state), so a plain Arc shares it, and removing
Clone here closes the door on silently reintroducing the per-request
deep clone this RFC exists to remove.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.config: Config§middlewares: LoadedMiddlewares§tracer: TraceEmitterLive match-trace channel. Shared across all request handler tasks.
Implementations§
Source§impl AppState
impl AppState
pub fn new( config: Config, middlewares: LoadedMiddlewares, tracer: TraceEmitter, ) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for AppState
impl !UnwindSafe for AppState
impl Freeze for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
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
Mutably borrows from an owned value. Read more