he_di_derive 0.2.1

Code generation for he_di dependency injection / inversion of control framework
docs.rs failed to build he_di_derive-0.2.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: he_di_derive-0.2.0

he_di provides a derive macro to generate implementations of the Component traits for data structures defined in your crate, allowing them to be 'registered' and 'resolved' from a Container

This functionality is based on Rust's #[derive] mechanism, just like what you would use to automatically derive implementations of the built-in Clone, Copy, Debug, or other traits. It is able to generate implementations for most structs. For now enums including ones with elaborate generic types or trait bounds. On rare occasions, for an especially convoluted type you may need to implement the trait manually.


These derives require a Rust compiler version 1.15 or newer.

  • Add he_di = "0.2" as a dependency in Cargo.toml.
  • Add he_di_derive = "0.2" as a dependency in Cargo.toml.
  • If you have a main.rs, add #[macro_use] extern crate he_di_derive there.
  • If you have a lib.rs, add #[macro_use] extern crate he_di_derive there.
  • Use #[derive(Component)] on structs that you want to flag as Component which you want to inject or be injected.
  • Specify the interface this Component is implementing through #[interface(MyTrait)]

#[derive(Component)] macro

Supported attributes

  • interface: for a struct, name of the Trait that this Component will implement
  • inject: for a struct's property, tag a property as being a dependency to another Component (currently only supports Box<Interface> synthax)