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.
Catalog::scope
andCatalog::current
allow setting and accessing a "current" catalog in a task-local context- Requires new
tokio
crate feature
- Requires new
Lazy<T>
injection spec that delays the creation of a value until it's requested- Can be used to delay initialization of expensive values that are rarely used
- Can be used in combination with
Catalog::scope
to inject values registered dynamically
- Upgraded to
thiserror v2
dependency
Catalog::builder()
andcatalog.builder_chained()
shortcuts- New
examples
directory to showcase DI patterns and integrations
Catalog::builders_for_with_meta()
works corectly for chained catalogs
- It's now possible to associate custom static metadata with builders:
#[component] #[interface(dyn EventHandler)] #[meta(EventHandlerDesc { event_type: "A"})] #[meta(EventHandlerDesc { event_type: "B"})] struct EventHandlerAB;
- New
BuilderExt
trait was added to provide convenient access to metadata and interfaces - New
Catalog::builders_for_with_meta()
allows to filter builders by metadata with a custom predicate
Builder::interfaces
method was changed to iteration via callback to avoid allocating aVec
- Fixed pedantic linter warnings
- Added
interface(T)
macro attribute to provide default interface bindings for the component builders, allowing to cut down verboseness of catalog configuration. Example:trait Iface {} #[dill::component] #[dill::interface(dyn Iface)] struct Impl; // Automatically does `.bind::<dyn Iface, Impl>()` Catalog::builder().add::<Impl>().build();
- Fixed validation of Catalog self-injection
- Linked with latest dependencies
- Basic support for chaining catalogs
- Account for overridden fields in generated builders when validating dependencies
CatalogBuilder::add_builder()
now acceptsArc<T>
andFn() -> Arc<T>
CatalogBuilder::add_factory()
was replaced byCatalogBuilder::add_value_lazy()
that acceptsFnOnce() -> T
and will cache result forever
- Deduplicating errors in
ValidationError
CatalogBuilder::validate()
now allows to specify types that are registered dynamically and should not be considered unresolved
- Keeping a CHANGELOG
CatalogBuilder::validate()
function to validate the dependency graphMaybe
spec for optional dependencies- Derive macros now support injecting
Option<T>
(resolves toMaybe<T>
spec) andVec<T>
(resolves toAllOf<T>
spec)