Expand description
Shaku is a compile time dependency injection library. It can be used directly or through
integration with application frameworks such as Rocket (see
shaku_rocket).
§Getting started
See the getting started guide
§Crate features
By default shaku is thread-safe and exposes macros, but these can be disabled by opting out of the following features:
thread_safe: Requires components to beSend + Syncderive: Uses theshaku_derivecrate to provide proc-macro derives ofComponentandProvider, and themodulemacro.
Modules§
- guide
- Getting started guide
Macros§
Structs§
- Module
Build Context - Builds a
Moduleand its associated components. Build context, such as parameters and resolved components, are stored in this struct. - Module
Builder - Builds a
Module. Component parameters can be set, and both components and providers implementations can be overridden.
Traits§
- Component
- Components provide a service by implementing an interface. They may use other components as dependencies.
- HasComponent
- Indicates that a module contains a component which implements the interface.
- HasProvider
- Indicates that a module contains a provider which implements the interface.
- Interface
- Interfaces must be
'staticin order to be stored in a module (hence theAnyrequirement). - Module
- A module represents a group of services. By implementing traits such as
HasComponenton a module, service dependencies are checked at compile time. At runtime, modules hold the components they are associated with. - Module
Interface - Submodules must be
'staticin order to be stored in other modules (hence theAnyrequirement). - Provider
- Like
Components, providers provide a service by implementing an interface.
Type Aliases§
- Component
Fn - The type signature of
Component::buildwithout the parameters. This is used when overriding a component viaModuleBuilder::with_component_override_fn - Provider
Fn - The type signature of
Provider::provide. This is used when overriding a provider viaModuleBuilder::with_provider_override