Skip to main content

RegistrationHelper

Struct RegistrationHelper 

Source
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>

Source

pub fn to_constant(self, constant: Rc<T>) -> &'a FerroLocator

Every lookup returns constant.

Source

pub fn to_func( self, func: impl Fn() -> Option<Rc<T>> + 'static, ) -> &'a FerroLocator

Every lookup calls func.

Source

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.

Source

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.

Source

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>
where PhantomData<fn() -> Rc<T>>: Freeze, T: ?Sized,

§

impl<'a, T> Unpin for RegistrationHelper<'a, T>
where PhantomData<fn() -> Rc<T>>: Unpin, T: ?Sized,

§

impl<'a, T> UnsafeUnpin for RegistrationHelper<'a, T>
where PhantomData<fn() -> Rc<T>>: UnsafeUnpin, T: ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.