[−][src]Struct roa::SyncContext
Sync parts of Context.
Fields
exec: Executor
Application level runtime.
remote_addr: SocketAddr
Socket addr of last client or proxy.
Methods
impl<S> SyncContext<S>
[src]
pub fn store_scoped<SC, T>(
&mut self,
_scope: SC,
name: &'a str,
value: T
) -> Option<Variable<'a, T>> where
SC: Any,
T: Any + Send + Sync,
[src]
&mut self,
_scope: SC,
name: &'a str,
value: T
) -> Option<Variable<'a, T>> where
SC: Any,
T: Any + Send + Sync,
Store key-value pair in specific scope.
Example
use roa_core::App; use roa_core::http::{StatusCode, Method}; struct Scope; struct AnotherScope; let mut app = App::new(()); app.gate_fn(|mut ctx, next| async move { ctx.store_scoped(Scope, "id", "1".to_string()); next.await }); app.end(|ctx| async move { assert_eq!(1, ctx.load_scoped::<Scope, String>("id").unwrap().parse::<i32>()?); assert!(ctx.load_scoped::<AnotherScope, String>("id").is_none()); Ok(()) });
pub fn store<T>(&mut self, name: &'a str, value: T) -> Option<Variable<'a, T>> where
T: Any + Send + Sync,
[src]
T: Any + Send + Sync,
Store key-value pair in public scope.
Example
use roa_core::App; use roa_core::http::{StatusCode, Method}; let mut app = App::new(()); app.gate_fn(|mut ctx, next| async move { ctx.store("id", "1".to_string()); next.await }); app.end(|ctx| async move { assert_eq!(1, ctx.load::<String>("id").unwrap().parse::<i32>()?); Ok(()) });
pub fn load_scoped<SC, T>(&self, name: &'a str) -> Option<Variable<'a, T>> where
SC: Any,
T: Any + Send + Sync,
[src]
SC: Any,
T: Any + Send + Sync,
Search for value by key in specific scope.
Example
use roa_core::App; struct Scope; let mut app = App::new(()); app.gate_fn(|mut ctx, next| async move { ctx.store_scoped(Scope, "id", "1".to_owned()); next.await }); app.end(|ctx| async move { assert_eq!(1, ctx.load_scoped::<Scope, String>("id").unwrap().parse::<i32>()?); Ok(()) });
pub fn load<T>(&self, name: &'a str) -> Option<Variable<'a, T>> where
T: Any + Send + Sync,
[src]
T: Any + Send + Sync,
Search for value by key in public scope.
Example
use roa_core::App; let mut app = App::new(()); app.gate_fn(|mut ctx, next| async move { ctx.store("id", "1".to_string()); next.await }); app.end(|ctx| async move { assert_eq!(1, ctx.load::<String>("id").unwrap().parse::<i32>()?); Ok(()) });
Trait Implementations
impl<S> Clone for SyncContext<S> where
S: Clone,
[src]
S: Clone,
fn clone(&self) -> SyncContext<S>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<S> CookieGetter for SyncContext<S>
[src]
fn must_cookie(&mut self, name: &str) -> Result<Arc<Cookie<'static>>>
[src]
fn cookie(&self, name: &str) -> Option<Arc<Cookie<'static>>>
[src]
impl<S> Deref for SyncContext<S>
[src]
type Target = S
The resulting type after dereferencing.
fn deref(&self) -> &<SyncContext<S> as Deref>::Target
[src]
impl<S> DerefMut for SyncContext<S>
[src]
fn deref_mut(&mut self) -> &mut <SyncContext<S> as Deref>::Target
[src]
impl<S> JwtVerifier<S> for SyncContext<S> where
S: State,
[src]
S: State,
fn claims<C>(&self) -> Result<C> where
C: 'static + DeserializeOwned,
[src]
C: 'static + DeserializeOwned,
fn verify<C>(&self, validation: &Validation) -> Result<C> where
C: 'static + DeserializeOwned,
[src]
C: 'static + DeserializeOwned,
impl<S: State> Query for SyncContext<S>
[src]
Auto Trait Implementations
impl<S> !RefUnwindSafe for SyncContext<S>
impl<S> Send for SyncContext<S> where
S: Send,
S: Send,
impl<S> Sync for SyncContext<S> where
S: Sync,
S: Sync,
impl<S> Unpin for SyncContext<S> where
S: Unpin,
S: Unpin,
impl<S> !UnwindSafe for SyncContext<S>
Blanket Implementations
impl<T, A, P> Access<T> for P where
A: Access<T>,
P: Deref<Target = A>,
[src]
A: Access<T>,
P: Deref<Target = A>,
type Guard = <A as Access<T>>::Guard
A guard object containing the value and keeping it alive. Read more
fn load(&self) -> <P as Access<T>>::Guard
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, A> DynAccess<T> for A where
A: Access<T>,
<A as Access<T>>::Guard: 'static,
[src]
A: Access<T>,
<A as Access<T>>::Guard: 'static,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> State for T where
T: 'static + Clone + Send + Sync,
[src]
T: 'static + Clone + Send + Sync,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,