pub struct AppState {
pub allowed_origins: Vec<String>,
pub allowed_methods: Vec<Method>,
pub body_config: BodyConfig,
/* private fields */
}Expand description
Type-safe container for custom application state
Fields§
§allowed_origins: Vec<String>Built-in CORS configuration
allowed_methods: Vec<Method>Built-in allowed HTTP methods
body_config: BodyConfigBuilt-in HTTP body configuration
Implementations§
Source§impl AppState
impl AppState
pub fn new( allowed_origins: Vec<String>, allowed_methods: Vec<Method>, body_config: BodyConfig, custom_state: HashMap<String, Box<dyn Any + Send + Sync>>, ) -> Self
pub fn builder(body_config: BodyConfig) -> AppStateBuilder
Sourcepub fn get<T: Send + Sync + 'static>(&self, key: &str) -> Option<&T>
pub fn get<T: Send + Sync + 'static>(&self, key: &str) -> Option<&T>
Get a reference to a value from the custom state storage
pub fn contains_key(&self, key: &str) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter_custom_state( &self, ) -> impl Iterator<Item = (&String, &Box<dyn Any + Send + Sync>)>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AppState
impl !RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
impl !UnwindSafe 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