pub struct ContextBuilder { /* private fields */ }Implementations§
Source§impl ContextBuilder
impl ContextBuilder
pub fn config(self, config: Config) -> Self
Sourcepub fn state<T: Send + Sync + 'static>(self, value: T) -> Self
pub fn state<T: Send + Sync + 'static>(self, value: T) -> Self
Register a service. One value per type; registering twice replaces.
Sourcepub fn registered<T: Send + Sync + 'static>(&self) -> Option<&T>
pub fn registered<T: Send + Sync + 'static>(&self) -> Option<&T>
What was registered under this type, before the context is built.
The console commands need it: migrate used to build a second database
connection from DATABASE_URL, ignoring the one the application had
already opened. For an application whose handle comes from anywhere else
— a second key, a vault lease, a tenant lookup — that is a migration run
against the wrong database, or against none.
Sourcepub fn has_state<T: Send + Sync + 'static>(&self) -> bool
pub fn has_state<T: Send + Sync + 'static>(&self) -> bool
Whether something of this type has already been registered.
For the case where the framework would otherwise supply a default and
quietly replace what the application built for itself — see how App
decides whether to construct a view engine.
pub fn build(self) -> Context
Auto Trait Implementations§
impl !RefUnwindSafe for ContextBuilder
impl !UnwindSafe for ContextBuilder
impl Freeze for ContextBuilder
impl Send for ContextBuilder
impl Sync for ContextBuilder
impl Unpin for ContextBuilder
impl UnsafeUnpin for ContextBuilder
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