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§

  • Getting started guide

Macros§

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

Structs§

  • Builds a Module and its associated components. Build context, such as parameters and resolved components, are stored in this struct.
  • Builds a Module. Component parameters can be set, and both components and providers implementations can be overridden.

Traits§

  • Components provide a service by implementing an interface. They may use other components as dependencies.
  • Indicates that a module contains a component which implements the interface.
  • Indicates that a module contains a provider which implements the interface.
  • Interfaces must be 'static in order to be stored in a module (hence the Any requirement).
  • 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.
  • Submodules must be 'static in order to be stored in other modules (hence the Any requirement).
  • Like Components, providers provide a service by implementing an interface.

Type Aliases§

Derive Macros§