pub struct RegistrationHelper<'a, T: ?Sized + 'static> { /* private fields */ }Expand description
Binds the service type T to an implementation; see
FerroLocator::bind.
Implementations§
Source§impl<'a, T: ?Sized + 'static> RegistrationHelper<'a, T>
impl<'a, T: ?Sized + 'static> RegistrationHelper<'a, T>
Sourcepub fn to_constant(self, constant: Rc<T>) -> &'a FerroLocator
pub fn to_constant(self, constant: Rc<T>) -> &'a FerroLocator
Every lookup returns constant.
Sourcepub fn to_func(
self,
func: impl Fn() -> Option<Rc<T>> + 'static,
) -> &'a FerroLocator
pub fn to_func( self, func: impl Fn() -> Option<Rc<T>> + 'static, ) -> &'a FerroLocator
Every lookup calls func.
Sourcepub fn to_lazy(
self,
func: impl Fn() -> Option<Rc<T>> + 'static,
) -> &'a FerroLocator
pub fn to_lazy( self, func: impl Fn() -> Option<Rc<T>> + 'static, ) -> &'a FerroLocator
The first lookup calls func; later lookups return what it produced.
Sourcepub fn to_singleton<TImpl: Default + 'static>(
self,
upcast: fn(Rc<TImpl>) -> Rc<T>,
) -> &'a FerroLocator
pub fn to_singleton<TImpl: Default + 'static>( self, upcast: fn(Rc<TImpl>) -> Rc<T>, ) -> &'a FerroLocator
The first lookup creates a TImpl, which every lookup then returns.
upcast converts the implementation handle to the service handle;
for a trait object service it is the identity closure
|instance| instance, which performs the unsizing coercion.
Sourcepub fn to_transient<TImpl: Default + 'static>(
self,
upcast: fn(Rc<TImpl>) -> Rc<T>,
) -> &'a FerroLocator
pub fn to_transient<TImpl: Default + 'static>( self, upcast: fn(Rc<TImpl>) -> Rc<T>, ) -> &'a FerroLocator
Every lookup creates a new TImpl. See
to_singleton for upcast.
Auto Trait Implementations§
impl<'a, T> !RefUnwindSafe for RegistrationHelper<'a, T>
impl<'a, T> !Send for RegistrationHelper<'a, T>
impl<'a, T> !Sync for RegistrationHelper<'a, T>
impl<'a, T> !UnwindSafe for RegistrationHelper<'a, T>
impl<'a, T> Freeze for RegistrationHelper<'a, T>
impl<'a, T> Unpin for RegistrationHelper<'a, T>
impl<'a, T> UnsafeUnpin for RegistrationHelper<'a, T>
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
The static constructor of a type: work done once per thread, after
the properties of the type are registered and before its first
instance exists (class handlers,
affects_render, metadata
overrides). Read more