Expand description
A small, explicit dependency-injection runtime for Axum applications.
Container owns application providers while ModuleGraph verifies module
boundaries before the application starts. The older Injector API is
retained for applications migrating from the first preview release.
Re-exports§
pub use middleware::Application;pub use versioning::ApiVersion;pub use versioning::ApiVersions;pub use versioning::VersionError;
Modules§
- config
- Typed configuration readers and redacted validation errors. Typed environment access with value-redacted validation errors.
- exceptions
- Safe HTTP error envelopes, normalization, and request correlation. Consistent error envelopes and explicit mappings from domain errors.
- middleware
- HTTP middleware and application pipeline composition. Ordered HTTP middleware for applications, controllers, and routes.
- prelude
- Common controller types and macros.
- versioning
- Explicit route version groups and per-version OpenAPI metadata. Explicit URL version groups with independently validated OpenAPI documents.
Structs§
- ApiOperation
- Route documentation collected by
#[routes]; this is metadata, not an OpenAPI schema. - ApiResponse
- Documentation attached to one declared controller response.
- Container
- Thread-safe provider container with shared singleton and isolated request caches.
- Container
Builder - Builds a validated
Container. - Documentation
Error - Invalid or conflicting route documentation discovered before serving traffic.
- Http
Error - Safe HTTP failure with a JSON envelope; request boundaries add correlation IDs.
- Inject
- Extract a provider using the request’s shared dependency scope.
Install
with_containeronce on assembled routes, or use a generatedscoped_router. - Injector
- Compatibility injector storing cloneable application values.
- Module
Definition - Declarative module metadata, used to validate imports and exports.
- Module
Graph - Validates module metadata and flattens modules into a container.
- Provider
Definition - A provider registration. Dependencies are metadata used for startup validation.
- Provider
Key - A type-safe key used to identify a provider.
- Request
Scope - Owned request-local provider cache. Clones share only this request’s values. Returned Arcs can outlive the HTTP request if retained by application code.
- Validated
Json - JSON extractor used by generated
#[body]adapters to validate DTOs automatically. - Validated
Query - Query extractor used by generated
#[query]adapters to validate DTOs automatically.
Enums§
- Inject
Error - Errors discovered while constructing or validating an application.
- Scope
- The lifecycle of a provider instance.
Traits§
- Injectable
- Compatibility construction contract for applications using the original injector.
- Provider
- Types generated by
#[injectable]can register themselves with a container.
Functions§
- json_
schema - Generate a schema using the same Serde contract as the DTO or response entity.
- openapi_
document - Build an OpenAPI 3.1 document; reject duplicate paths, IDs, and schema names.
- with_
container - Create a fresh DI cache for each request before running controller middleware/extractors. Singleton caches are shared across requests; dropping a request releases its cached values.
Type Aliases§
- Http
Status - HTTP status codes usable by controllers without importing Axum internals.
- Request
Container - Compatibility name for the owned request scope; the lifetime no longer restricts ownership.
Existing
RequestContainer<'a>type annotations continue to compile.
Attribute Macros§
- body
- Preserve this annotation for the owning route or module macro.
- controller
- Generate a controller router from method route attributes.
- delete
- Declare an HTTP DELETE handler.
- exception
- Preserve this annotation for the owning route or module macro.
- extension
- Preserve this annotation for the owning route or module macro.
- get
- Declare an HTTP GET handler.
- global
- Marks a module as globally visible. It is consumed by
#[module]. - guard
- Preserve this annotation for the owning route or module macro.
- head
- Declare an HTTP HEAD handler.
- header
- Preserve this annotation for the owning route or module macro.
- injectable
- Generate dependency-injection factories for a struct.
- interceptor
- Preserve this annotation for the owning route or module macro.
- middleware
- Declare ordered controller or route middleware under
#[controller]or#[routes]. - module
- Declare module providers, imports, and exported dependencies.
- on_
bootstrap - Preserve this annotation for the owning route or module macro.
- on_
module_ destroy - Preserve this annotation for the owning route or module macro.
- on_
module_ init - Preserve this annotation for the owning route or module macro.
- on_
shutdown - Preserve this annotation for the owning route or module macro.
- options
- Declare an HTTP OPTIONS handler.
- param
- Preserve this annotation for the owning route or module macro.
- patch
- Declare an HTTP PATCH handler.
- post
- Declare an HTTP POST handler.
- put
- Declare an HTTP PUT handler.
- query
- Preserve this annotation for the owning route or module macro.
- request
- Preserve this annotation for the owning route or module macro.
- routes
- Generate an Axum router for an inherent controller implementation.
- scope
- Selects the provider lifecycle used by
#[injectable](singleton,transient, orrequest). - state
- Preserve this annotation for the owning route or module macro.
- test_
module - Preserve this annotation for the owning route or module macro.
- validate
- Preserve this annotation for the owning route or module macro.
Derive Macros§
- Injectable
- Derive dependency-injection factories without changing the struct declaration.