All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.6.2 - 2024-08-31
- Switched from
anymap
toanymap2
to fix a possible soundness bug. See RUSTSEC-2021-0065 (thanks @wolpert)
- Updated to support Rocket 0.5.0 (thanks @BennyPLS)
- Updated to axum 0.7
- Updated to axum 0.6
- Updated to actix 4.0
- Updated to axum 0.5
- Updated to axum 0.4
- Initial release (thanks @Dispersia!). See #31.
- Update Rocket to 0.5.0-rc.1
- The
Component
derive now documents the generated parameters struct. The struct is documented as "Parameters for {component}" while the fields use the documentation attached to the original fields.
- Modules must now be inserted into Rocket's state wrapped in a
Box
. This supports inserting module trait objects (e.g.Box<dyn MyModule>
).
- Added support for module trait objects. This is useful if the module changes
at runtime (e.g. production vs development modules):
trait MyModule: HasComponent<dyn MyService> {} #[get("/")] fn index(service: Inject<dyn MyModule, dyn MyService>) { // ... }
-
Relaxed requirements on the module type in
Inject
andInjectProvided
to support module trait objects (e.g.Arc<dyn MyModule>
):trait MyModule: HasComponent<dyn MyService> {} async fn index(service: Inject<dyn MyModule, dyn MyService>) { // ... }
0.6.1 - 2021-02-05
- Added
ModuleBuilder::with_component_override_fn
. This will allow you to override a component with a mock that has injected fields (i.e. is aComponent
). See #24.
- Added links to the guides to the readme.
- Added a section to the readme on
Component
vsProvider
. - Additionally run the tests without the
thread_safe
feature in CI.
0.6.0 - 2021-01-09
- To support lazy components,
resolve_mut
is removed. It relied upon having a singleArc
reference to the component, which can not be guaranteed in many cases (including the case of lazy components). - To support lazy components, component parameters (the non-injected/provided
struct properties) must implement
Send
when thethread_safe
feature is enabled. Module::build
now takes theModuleBuildContext
by value instead of by mutable reference.- Component parameters no longer require
Default
by default (pun intended) when using the Component derive. If a parameter is not provided during module creation, there will be a panic. The#[shaku(default)]
and#[shaku(default = ...)]
annotations can be used to enable a default (first via theDefault
trait, second via the provided expression). The#[shaku(no_default)]
annotation has been removed since it is now the default.
- Components can now be lazily created. Annotate a component in the module with
#[lazy]
to make it lazy:Nowmodule! { MyModule { components = [#[lazy] ServiceImpl], providers = [] } }
ServiceImpl
will not be created untilresolve
orresolve_ref
is called to access it, or until it is required by another component/provider.
- Improved macro error messages by highlighting the relevant piece of code in
the error (via
syn::Error
).
- Fixed accidentally importing
syn::export::Hash
, which is not part of the public API.
- New crate added to support Actix Web. It functions similarly to shaku_rocket. It works with both shaku 0.5 and 0.6.
- This version supports both shaku 0.5 and 0.6. This crate is now independently versioned from the main shaku crate.
0.5.0 - 2020-06-19
- The
module
macro is now a procedural macro and thus requires thederive
feature. - The
module
macro can no longer be used in statement position until 1.45, when support for proc-macros in that position becomes stable.
- The
module
macro now supports associated types in generic module bounds and where clauses on the module. - A new annotation for properties without a default is added:
#[shaku(no_default)]
. If the parameters are not provided for a component with such a property, there will be a panic during module creation (unless the component is overridden). See theno_default_parameter
test for an example.
0.4.1 - 2020-06-01
- Support generics in derives and the
module
macro. For example:use shaku::{module, Component, Interface, HasComponent}; trait MyComponent<T: Interface>: Interface {} #[derive(Component)] #[shaku(interface = MyComponent<T>)] struct MyComponentImpl<T: Interface + Default> { value: T } impl<T: Interface + Default> MyComponent<T> for MyComponentImpl<T> {} module! { MyModule<T: Interface + Default> { components = [MyComponentImpl<T>], providers = [] } }
0.4.0 - 2020-05-26
- Container is dead, long live Module! Resolving services now deals with modules
instead of a Container of the module. Instead of building a container, you
build the module. Instead of calling
Container::resolve
, now you call the module'sHasComponent::resolve
method (similar for providers). The methods inHasComponent
have been changed to match the oldContainer
methods.ContainerBuilder
has been renamed toModuleBuilder
and is normally created by calling the generatedbuilder
method on the module to be build. - Modules can depend on module interfaces, i.e., traits which have
HasComponent
/HasProvider
bounds. Because of this, the submodules must be provided to the module builder during module build. See the module macro documentation for more details. ProvidedInterface
has been removed. Consequently, provided services do not need to implementSend
to be thread-safe anymore.
- Added
ModuleInterface
to automatically enforce submodule thread-safety. It is a trait alias functionally equivalent toInterface
. User code should never have to reference it as it is a supertrait ofModule
,HasComponent
, andHasProvider
so it comes "for free". - Added an optional module interface specifier to the module macro (add
: MyModuleInterface
after the module name). If a module interface is specified, the generated module will implement it. - Added a submodule guide
- shaku_rocket now ensures that the thread_safe feature is enabled.
0.3.1 - 2020-05-11
- Fix "no function or associated item named ..." errors when using the
module
macro to generate a module and certain traits are not in scope.
0.3.0 - 2020-05-09
- Support submodules. Modules can now wrap other modules and use services from them. Modules can have multiple submodules.
- Add "submodule containers" (a type of
Container
) to support submodules. Normally these will only be used inHasProvider
implementations.
- Renamed
ContainerBuildContext
toModuleBuildContext
and modified some function signatures to support submodules. Container
now has a lifetime parameter to support submodule containers. Normally this lifetime is eluded, so you shouldn't need to change your code.- Moved getting started guides to dedicated module.
0.2.0 - 2020-02-23
- Now uses compile time magic (generics) to check the dependency graph. This involves a lot of internal changes, although upgrading should be straightforward (add a Module type via the module macro and update ContainerBuilder usage).
- Minimum supported Rust version changed to 1.38.0 (from 1.40.0)
- Removed log dependency
0.1.0 - 2020-02-06
- Initial release