ServiceBinder

Trait ServiceBinder 

Source
pub trait ServiceBinder {
Show 14 methods // Required methods fn add_service_descriptor( &mut self, descriptor: ServiceDescriptor, ) -> Result<&mut Self, CoreError>; fn bind<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> &mut Self; fn bind_singleton<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> &mut Self; fn bind_transient<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> &mut Self; fn bind_factory<TInterface: ?Sized + 'static, F, T>( &mut self, factory: F, ) -> &mut Self where F: Fn() -> Result<T, CoreError> + Send + Sync + 'static, T: Send + Sync + 'static; fn bind_instance<TInterface: ?Sized + 'static, TImpl: Send + Sync + Clone + 'static>( &mut self, instance: TImpl, ) -> &mut Self; fn bind_named<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, name: &str, ) -> &mut Self; fn bind_injectable<T: Injectable>(&mut self) -> &mut Self; fn bind_injectable_singleton<T: Injectable>(&mut self) -> &mut Self; fn bind_with<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> AdvancedBindingBuilder<TInterface>; fn with_implementation<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, config: BindingConfig, ) -> &mut Self; fn bind_lazy<TInterface: ?Sized + 'static, F, T>( &mut self, factory: F, ) -> &mut Self where F: Fn() -> T + Send + Sync + 'static, T: Send + Sync + 'static; fn bind_parameterized_factory<TInterface: ?Sized + 'static, P, F, T>( &mut self, factory: F, ) -> &mut Self where F: Fn(P) -> Result<T, CoreError> + Send + Sync + 'static, T: Send + Sync + 'static, P: Send + Sync + 'static; fn bind_collection<TInterface: ?Sized + 'static, F>( &mut self, configure: F, ) -> &mut Self where F: FnOnce(&mut CollectionBindingBuilder<TInterface>);
}
Expand description

Binding API for the IoC container

Required Methods§

Source

fn add_service_descriptor( &mut self, descriptor: ServiceDescriptor, ) -> Result<&mut Self, CoreError>

Add a pre-built service descriptor

Source

fn bind<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> &mut Self

Bind an interface to an implementation

Source

fn bind_singleton<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> &mut Self

Bind an interface to an implementation with singleton lifetime

Source

fn bind_transient<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> &mut Self

Bind an interface to an implementation with transient lifetime

Source

fn bind_factory<TInterface: ?Sized + 'static, F, T>( &mut self, factory: F, ) -> &mut Self
where F: Fn() -> Result<T, CoreError> + Send + Sync + 'static, T: Send + Sync + 'static,

Bind a service using a factory function

Source

fn bind_instance<TInterface: ?Sized + 'static, TImpl: Send + Sync + Clone + 'static>( &mut self, instance: TImpl, ) -> &mut Self

Bind a pre-created instance

Source

fn bind_named<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, name: &str, ) -> &mut Self

Bind a named service

Source

fn bind_injectable<T: Injectable>(&mut self) -> &mut Self

Bind an Injectable service with auto-wiring

Source

fn bind_injectable_singleton<T: Injectable>(&mut self) -> &mut Self

Bind an Injectable service as singleton with auto-wiring

Source

fn bind_with<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> AdvancedBindingBuilder<TInterface>

Advanced bind with fluent configuration - returns builder for chaining

Source

fn with_implementation<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, config: BindingConfig, ) -> &mut Self

Complete advanced binding with implementation

Source

fn bind_lazy<TInterface: ?Sized + 'static, F, T>( &mut self, factory: F, ) -> &mut Self
where F: Fn() -> T + Send + Sync + 'static, T: Send + Sync + 'static,

Bind a lazy service using factory that gets called only when needed

Source

fn bind_parameterized_factory<TInterface: ?Sized + 'static, P, F, T>( &mut self, factory: F, ) -> &mut Self
where F: Fn(P) -> Result<T, CoreError> + Send + Sync + 'static, T: Send + Sync + 'static, P: Send + Sync + 'static,

Bind with parameterized factory

Source

fn bind_collection<TInterface: ?Sized + 'static, F>( &mut self, configure: F, ) -> &mut Self
where F: FnOnce(&mut CollectionBindingBuilder<TInterface>),

Bind a collection of services using a closure-based configuration

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§