Example
/////////////////////////////////////////
// Define interfaces in traits
// Implement traits to define components
/////////////////////////////////////////
;
/////////////////////////////////////////
// Register interfaces and bind them to implementations
let cat = new
.
.
.
.
.build;
// Get objects and have their deps satisfied automatically
let inst = cat..unwrap;
assert_eq!;
TODO
- Add
trybuild
tests (see https://youtu.be/geovSK3wMB8?t=956) - Support generic types
- Replace
add_*
with genericadd<B: Into<Builder>>
- value by reference in new()
- scopes
- invocation
- thread
- task
- catalog?
- thread safety
- adding values to catalog dynamically
- lazy values
- externally defined types
- custom builders
- error handling
- doctests
- Advanced queries (based on metadata + custom filters)
- improve catalog fluent interface (or macro?)
- proc macro error handling
- build a type without registering
Done
- multiple implementations per interface
- implementation-controlled sharing and lifetime
- dependency specs
- OneOf
- AllOf
- scopes
- transient
- singleton
- auto builders
- support scope in derivation
- support prebuilt / add by value
- support Impl::new()
- argument bindings
- by value injection of
Clone
types - Separate catalog use from catalog building
- Make Catalog cloning cheap
- Catalog self-injection
Principles
-
Nothing framework-specific
-
Create instance (ctor, new(), and external types)
-
Provide dynamic dependencies -> recurse
-
Provide fixed dependencies (Fn multi)
-
Get existing instance if exists (scope)
-
Separate builder from the scope, catalog, Arc stuff
-
Pass build context instead of catalog (e.g. for stack tracking)