pub struct AppState<T> { /* private fields */ }Expand description
Wraps a value so it can be used as application state with DefaultError.
AppState<T> implements State for any 'static T, so a separate
State implementation is not needed. It dereferences to the wrapped value
and implements Clone and Default when T does.
use ntex::web;
#[derive(Clone)]
struct Settings {
service_name: &'static str,
}
let state = web::AppState::new(Settings { service_name: "users" });
assert_eq!(state.service_name, "users");Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for AppState<T>where
T: Freeze,
impl<T> RefUnwindSafe for AppState<T>where
T: RefUnwindSafe,
impl<T> Send for AppState<T>where
T: Send,
impl<T> Sync for AppState<T>where
T: Sync,
impl<T> Unpin for AppState<T>where
T: Unpin,
impl<T> UnsafeUnpin for AppState<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AppState<T>where
T: UnwindSafe,
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