Expand description
Utility library for injecting dependencies into actix-web applications.
Modules§
- Additional documentation modules.
Macros§
- Defines a new module using a domain specific language.
- Marks a trait as being an interface for many other types. This means that a request for the given trait can resolve to any of the types indicated by this macro invocation.
Structs§
- Allows custom pre-defined values to be passed as arguments to services.
- A
TypedProvider
which conditionally provides its service. If the condition is not met, then the provider is skipped during resolution. - A provider which returns a constant, predetermined value. Note that this is technically a singleton service in that it does not recreate the value each time it is requested.
- Lazy request factory allowing requests to be made outside of service creation.
- A service factory that may fail during service creation with a custom error type. During activation failure, an instance of
InjectError::ActivationFailed
is returned as an error. - An injected request. Any request to the
Injector
can be injected by wrapping it in this type and providing it as a parameter to your request handler. - A runtime dependency injection container. This holds all the bindings between service types and their providers, as well as all the mappings from interfaces to their implementations (if they differ).
- A builder for an
Injector
. - Provides a service as an implementation of an interface. See
TypedProvider::with_interface()
for more information. - A collection of providers that can be added all at once to an
InjectorBuilder
. Modules can be used to group together related services and configure the injector in pieces rather than all at once. - An iterator over all the implementations of an interface. Each service is activated on demand.
- Information about an active request.
- Type information about a service.
- A collection of all the providers for a particular interface.
- An iterator over all the implementations of an interface. Each service is activated on demand.
- A service provider that only creates a single instance of the service. The service is created only during its first request. Any subsequent requests return service pointers to the same service.
- A service provider that creates an instance of the service each time it is requested. This will never return two service pointers to the same instance of a service.
Enums§
- An error occurred while injecting an instance of
Arg<T>
. - An error that has occurred during creation of a service.
Traits§
- Defines a conversion for a type into an
dyn Any
trait object. - Indicates functionality that can be implemented.
- Marker trait that indicates that a type is an interface for another type.
- Defines a conversion into a fallible service factory. This trait is automatically implemented for all service factories that return a
Result<T, E>
with an error type that implementsError
andService
. - Defines a conversion into a singleton provider. This trait is automatically implemented for all service factories.
- Defines a conversion into a transient provider. This trait is automatically implemented for all service factories.
- Weakly typed service provider.
- A request to an injector.
- A parameter for configuring requested services.
- Implemented automatically on types that are capable of being a service.
- A factory for creating instances of a service. All functions of arity 12 or less are automatically service factories if the arguments to that function are valid service requests and the return value is a valid service type.
- A strongly-typed service provider.
- Allows defining pre-defined arguments to services.
- Defines a conversion into a conditional provider. This trait is automatically implemented for all types that implement
TypedProvider
.
Functions§
- Create a provider from a constant value.
Type Aliases§
- A reference-counted service pointer holding an instance of
dyn Any
. - A result from attempting to inject dependencies into a service and construct an instance of it.
- An owned service pointer holding an instance of
dyn Any
. - A reference-counted pointer holding a service. The pointer type is determined by the feature flags passed to this crate.