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§
Sourcefn add_service_descriptor(
&mut self,
descriptor: ServiceDescriptor,
) -> Result<&mut Self, CoreError>
fn add_service_descriptor( &mut self, descriptor: ServiceDescriptor, ) -> Result<&mut Self, CoreError>
Add a pre-built service descriptor
Sourcefn bind<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>(
&mut self,
) -> &mut Self
fn bind<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> &mut Self
Bind an interface to an implementation
Sourcefn bind_singleton<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
Bind an interface to an implementation with singleton lifetime
Sourcefn bind_transient<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
Bind an interface to an implementation with transient lifetime
Sourcefn bind_factory<TInterface: ?Sized + 'static, F, T>(
&mut self,
factory: F,
) -> &mut Self
fn bind_factory<TInterface: ?Sized + 'static, F, T>( &mut self, factory: F, ) -> &mut Self
Bind a service using a factory function
Sourcefn bind_instance<TInterface: ?Sized + 'static, TImpl: Send + Sync + Clone + 'static>(
&mut self,
instance: TImpl,
) -> &mut Self
fn bind_instance<TInterface: ?Sized + 'static, TImpl: Send + Sync + Clone + 'static>( &mut self, instance: TImpl, ) -> &mut Self
Bind a pre-created instance
Sourcefn bind_named<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>(
&mut self,
name: &str,
) -> &mut Self
fn bind_named<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, name: &str, ) -> &mut Self
Bind a named service
Sourcefn bind_injectable<T: Injectable>(&mut self) -> &mut Self
fn bind_injectable<T: Injectable>(&mut self) -> &mut Self
Bind an Injectable service with auto-wiring
Sourcefn bind_injectable_singleton<T: Injectable>(&mut self) -> &mut Self
fn bind_injectable_singleton<T: Injectable>(&mut self) -> &mut Self
Bind an Injectable service as singleton with auto-wiring
Sourcefn bind_with<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>(
&mut self,
) -> AdvancedBindingBuilder<TInterface>
fn bind_with<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, ) -> AdvancedBindingBuilder<TInterface>
Advanced bind with fluent configuration - returns builder for chaining
Sourcefn with_implementation<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>(
&mut self,
config: BindingConfig,
) -> &mut Self
fn with_implementation<TInterface: ?Sized + 'static, TImpl: Send + Sync + Default + 'static>( &mut self, config: BindingConfig, ) -> &mut Self
Complete advanced binding with implementation
Sourcefn bind_lazy<TInterface: ?Sized + 'static, F, T>(
&mut self,
factory: F,
) -> &mut Self
fn bind_lazy<TInterface: ?Sized + 'static, F, T>( &mut self, factory: F, ) -> &mut Self
Bind a lazy service using factory that gets called only when needed
Sourcefn bind_parameterized_factory<TInterface: ?Sized + 'static, P, F, T>(
&mut self,
factory: F,
) -> &mut Self
fn bind_parameterized_factory<TInterface: ?Sized + 'static, P, F, T>( &mut self, factory: F, ) -> &mut Self
Bind with parameterized factory
Sourcefn bind_collection<TInterface: ?Sized + 'static, F>(
&mut self,
configure: F,
) -> &mut Selfwhere
F: FnOnce(&mut CollectionBindingBuilder<TInterface>),
fn bind_collection<TInterface: ?Sized + 'static, F>(
&mut self,
configure: F,
) -> &mut Selfwhere
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.