Struct dill::CatalogBuilder
source · pub struct CatalogBuilder { /* private fields */ }
Implementations§
source§impl CatalogBuilder
impl CatalogBuilder
pub fn new() -> Self
pub fn new_chained(chained_catalog: &Catalog) -> Self
sourcepub fn add<C: Component>(&mut self) -> &mut Self
pub fn add<C: Component>(&mut self) -> &mut Self
Registers a component using its associated builder.
Note that unline CatalogBuilder::add_builder() this will also bind the implementation to component’s default interfaces.
pub fn add_builder<Bld, Impl>(&mut self, builder: Bld) -> &mut Selfwhere Impl: 'static + Send + Sync, Bld: TypedBuilder<Impl> + 'static,
pub fn add_value<Impl>(&mut self, value: Impl) -> &mut Selfwhere Impl: 'static + Send + Sync,
sourcepub fn add_value_lazy<Fct, Impl>(&mut self, factory: Fct) -> &mut Selfwhere
Fct: FnOnce() -> Impl + Send + Sync + 'static,
Impl: Send + Sync + 'static,
pub fn add_value_lazy<Fct, Impl>(&mut self, factory: Fct) -> &mut Selfwhere Fct: FnOnce() -> Impl + Send + Sync + 'static, Impl: Send + Sync + 'static,
Uses the provided factory once and caches the instance in a Singleton scope
pub fn bind<Iface, Impl>(&mut self) -> &mut Selfwhere Iface: 'static + ?Sized, Impl: 'static + Send + Sync + Unsize<Iface>,
pub fn build(&mut self) -> Catalog
sourcepub fn validate(&mut self) -> Result<(), ValidationError>
pub fn validate(&mut self) -> Result<(), ValidationError>
Validates the dependency graph returning a combined error.
In case some of your types are registered dynamically you can ValidationErrorExt::ignore() method which is implemented on the Result type (you need to import the trait).
Example:
use dill::*;
trait MyDynamicType {}
let mut b = CatalogBuilder::new();
// Populate the builder
b.validate()
.ignore::<dyn MyDynamicType>()
.unwrap();
Trait Implementations§
source§impl Clone for CatalogBuilder
impl Clone for CatalogBuilder
source§fn clone(&self) -> CatalogBuilder
fn clone(&self) -> CatalogBuilder
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for CatalogBuilder
impl Send for CatalogBuilder
impl Sync for CatalogBuilder
impl Unpin for CatalogBuilder
impl !UnwindSafe for CatalogBuilder
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