speedyspec-container
A service container with the functionality of Laravel's: bindings, singletons, scoped instances, aliases, extenders, contextual bindings, tags and resolving callbacks, with worker and request lifetimes.
Part of the SpeedySpec platform.
Role: platform. Seam: container.
What it gives you
Container: bindings, singletons, scoped instances, aliases, extenders, contextual bindings (when), tags and resolving callbacks, with the functionality of Laravel's container.bind_port,singleton_portandmake_port: a port (a trait object) bound by key and resolved asRc<dyn Port>.Lifetime::WorkerandLifetime::Request:Container::end_requestdrops every request-lifetime entry and puts each key back on its worker entry.- Foreign entries (
bind_foreign,is_foreign): what a language bridge such asspeedyspec-container-phpregisters to override a Rust binding.
Install
Requirements
Rust 1.99.
Example
Bind a port to a named factory and resolve it.
use Rc;
use ;
;
let container = new;
container.;
let greeter = container..unwrap;
assert_eq!;
Where it fits
Every seam's contracts crate names its ports by key, and the runtime binds an implementation to each key here. PHP
overrides a binding through speedyspec-container-php, for one request. speedyspec-cqrs resolves its handlers
from this container. See the guide's container seam.
Versioning
SemVer, 0.x: a minor version may break the API. MSRV is Rust 1.99. SpeedySpec's own version (ADR-028) is the PHP runtime's major, not this crate's.
License
MIT