Struct silhouette::facade::Container
source · pub struct Container {}
Expand description
Static interface for the container.
Implementations§
source§impl Container
impl Container
sourcepub fn bind<T: 'static>(
factory: impl Fn(&Container) -> T + 'static + Sync + Send
) -> Result<(), Error>
pub fn bind<T: 'static>( factory: impl Fn(&Container) -> T + 'static + Sync + Send ) -> Result<(), Error>
Register a binding with the container.
Errors
This function will return an error if it fails to get write access to the container.
sourcepub fn bind_if<T: 'static>(
factory: impl Fn(&Container) -> T + 'static + Sync + Send
) -> Result<(), Error>
pub fn bind_if<T: 'static>( factory: impl Fn(&Container) -> T + 'static + Sync + Send ) -> Result<(), Error>
Register a binding if it hasn’t already been registered.
Errors
This function will return an error if it fails to get write access to the container.
sourcepub fn scoped<T: 'static + Clone + Send + Sync>(
factory: &(impl Fn(&Container) -> T + 'static)
) -> Result<(), Error>
pub fn scoped<T: 'static + Clone + Send + Sync>( factory: &(impl Fn(&Container) -> T + 'static) ) -> Result<(), Error>
Register a scoped binding in the container.
Errors
This function will return an error if it fails to get write access to the container.
sourcepub fn scoped_if<T: 'static + Clone + Send + Sync>(
factory: &(impl Fn(&Container) -> T + 'static)
) -> Result<(), Error>
pub fn scoped_if<T: 'static + Clone + Send + Sync>( factory: &(impl Fn(&Container) -> T + 'static) ) -> Result<(), Error>
Register a scoped binding if it hasn’t already been registered.
Errors
This function will return an error if it fails to get write access to the container.
sourcepub fn singleton<T: 'static + Clone + Send + Sync>(
factory: &(impl Fn(&Container) -> T + 'static)
) -> Result<(), Error>
pub fn singleton<T: 'static + Clone + Send + Sync>( factory: &(impl Fn(&Container) -> T + 'static) ) -> Result<(), Error>
Register a shared binding in the container.
Errors
This function will return an error if it fails to get write access to the container.
sourcepub fn singleton_if<T: 'static + Clone + Send + Sync>(
factory: &(impl Fn(&Container) -> T + 'static)
) -> Result<(), Error>
pub fn singleton_if<T: 'static + Clone + Send + Sync>( factory: &(impl Fn(&Container) -> T + 'static) ) -> Result<(), Error>
Register a shared binding if it hasn’t already been registered.
Errors
This function will return an error if it fails to get write access to the container.
sourcepub fn resolve<T: 'static>() -> Result<T, Error>
pub fn resolve<T: 'static>() -> Result<T, Error>
Resolve the given type from the container.
Errors
Returns an error if it fails to get read access to the container, if the requested type cannot be found, or if the requested type cannot be cast from the binding.