pub struct Handle<'m, T: ?Sized, K, C = K> { /* private fields */ }Expand description
What provide, value, the factory methods and the contribute builder return: a handle on
the binding registered by that call, through which its second keys, qualifier, construction bound,
readiness check and closure hooks are written.
Implementations§
Source§impl<'m, T: ?Sized + Send + Sync + 'static, K, C: SingleBinding> Handle<'m, T, K, C>
impl<'m, T: ?Sized + Send + Sync + 'static, K, C: SingleBinding> Handle<'m, T, K, C>
Sourcepub fn also_as<U: ?Sized + Send + Sync + 'static>(
self,
coerce: impl Fn(Arc<T>) -> Arc<U> + Send + Sync + 'static,
) -> Handle<'m, T, C, C>
pub fn also_as<U: ?Sized + Send + Sync + 'static>( self, coerce: impl Fn(Arc<T>) -> Arc<U> + Send + Sync + 'static, ) -> Handle<'m, T, C, C>
A second key under another type, reaching the same object: .also_as::<dyn Cache>(|a| a).
The closure’s return is where Arc<T> unsizes to Arc<U>; a T that does not implement
the trait fails to compile there.
Source§impl<'m, T: ?Sized, K, C: HookHost> Handle<'m, T, K, C>
impl<'m, T: ?Sized, K, C: HookHost> Handle<'m, T, K, C>
Sourcepub fn ready<Args, F, E>(
self,
check: F,
) -> Handle<'m, T, ReadyItem<Open, Open>, C>
pub fn ready<Args, F, E>( self, check: F, ) -> Handle<'m, T, ReadyItem<Open, Open>, C>
A readiness check, run right after the binding is constructed and before anything that
depends on it. A check that writes no bound takes construct_timeout as its attempt bound
when a Timer exists (§9.3). One check per binding; a second is a wiring error.
.retries(..) counts attempts after the first, zero unless written; .backoff(..) is the
wait between attempts, zero unless written.
Sourcepub fn on_init<Args, F, E>(self, hook: F) -> Handle<'m, T, HookItem<Open>, C>
pub fn on_init<Args, F, E>(self, hook: F) -> Handle<'m, T, HookItem<Open>, C>
An init hook, run once every singleton is built and checked, in connect order. Its Err
fails connect as ConnectError::Hook.
Sourcepub fn on_destroy<Args, F>(self, hook: F) -> Handle<'m, T, HookItem<Open>, C>
pub fn on_destroy<Args, F>(self, hook: F) -> Handle<'m, T, HookItem<Open>, C>
Runs after the drain, in reverse connect order.
Sourcepub fn before_shutdown<Args, F>(
self,
hook: F,
) -> Handle<'m, T, HookItem<Open>, C>where
F: ShutdownFactory<Args>,
pub fn before_shutdown<Args, F>(
self,
hook: F,
) -> Handle<'m, T, HookItem<Open>, C>where
F: ShutdownFactory<Args>,
Runs while the app still serves, before stop-accepting, with the shutdown’s signal.
Sourcepub fn on_shutdown<Args, F>(self, hook: F) -> Handle<'m, T, HookItem<Open>, C>where
F: ShutdownFactory<Args>,
pub fn on_shutdown<Args, F>(self, hook: F) -> Handle<'m, T, HookItem<Open>, C>where
F: ShutdownFactory<Args>,
Runs last in the shutdown sequence, after the sockets close, with the shutdown’s signal.
Source§impl<'m, T: ?Sized, K: Timeout<C>, C> Handle<'m, T, K, C>
impl<'m, T: ?Sized, K: Timeout<C>, C> Handle<'m, T, K, C>
Sourcepub fn timeout(self, d: Duration) -> Handle<'m, T, K::Next, K::Construction>
pub fn timeout(self, d: Duration) -> Handle<'m, T, K::Next, K::Construction>
Bounds the item written last: the construction directly after the binding is registered,
the whole check after .ready(..), the hook after an on_*. Needs a Timer; a wiring
error about the bound names this call. A zero duration is refused at wire(): write
unbounded for no bound.
Source§impl<'m, T: ?Sized, K: Unbounded<C>, C> Handle<'m, T, K, C>
impl<'m, T: ?Sized, K: Unbounded<C>, C> Handle<'m, T, K, C>
Sourcepub fn unbounded(self) -> Handle<'m, T, K::Next, K::Construction>
pub fn unbounded(self) -> Handle<'m, T, K::Next, K::Construction>
No bound on the item written last; still inside shutdown_timeout at shutdown.
Source§impl<'m, T: ?Sized, K: AttemptTimeout, C> Handle<'m, T, K, C>
impl<'m, T: ?Sized, K: AttemptTimeout, C> Handle<'m, T, K, C>
Sourcepub fn attempt_timeout(self, d: Duration) -> Handle<'m, T, K::Next, C>
pub fn attempt_timeout(self, d: Duration) -> Handle<'m, T, K::Next, C>
Bounds one attempt of the readiness check; an attempt that times out with retries left
is retried like one that returned Err. Needs a Timer; a wiring error about the bound
names this call. A zero duration is refused at wire().