Crate shaku

Source
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 be Send + Sync
  • derive: Uses the shaku_derive crate to provide proc-macro derives of Component and Provider, and the module macro.

Modules§

guide
Getting started guide

Macros§

module
Create a Module which is associated with some components and providers.

Structs§

ModuleBuildContext
Builds a Module and its associated components. Build context, such as parameters and resolved components, are stored in this struct.
ModuleBuilder
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 'static in order to be stored in a module (hence the Any requirement).
Module
A module represents a group of services. By implementing traits such as HasComponent on a module, service dependencies are checked at compile time. At runtime, modules hold the components they are associated with.
ModuleInterface
Submodules must be 'static in order to be stored in other modules (hence the Any requirement).
Provider
Like Components, providers provide a service by implementing an interface.

Type Aliases§

ComponentFn
The type signature of Component::build without the parameters. This is used when overriding a component via ModuleBuilder::with_component_override_fn
ProviderFn
The type signature of Provider::provide. This is used when overriding a provider via ModuleBuilder::with_provider_override

Derive Macros§

Component
Provider