pub struct State<T>(pub T);Expand description
Extracts application state.
Provides access to shared application state that was registered
with Rapina::state.
§Examples
ⓘ
use rapina::prelude::*;
#[derive(Clone)]
struct AppConfig {
db_url: String,
}
#[get("/config")]
async fn get_config(state: State<AppConfig>) -> String {
state.into_inner().db_url
}Tuple Fields§
§0: TImplementations§
Source§impl<T> State<T>
impl<T> State<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the extractor and returns the inner value.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for State<T>where
T: Freeze,
impl<T> RefUnwindSafe for State<T>where
T: RefUnwindSafe,
impl<T> Send for State<T>where
T: Send,
impl<T> Sync for State<T>where
T: Sync,
impl<T> Unpin for State<T>where
T: Unpin,
impl<T> UnwindSafe for State<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