Re-exports§
pub use rust_dix;pub use rust_dix_macros;pub use hyper;pub use serde;pub use serde_json;pub use tokio;
Macros§
Structs§
- AppOptions
- Standard application options loaded from appsettings.json.
- AppSection
- Top-level application section.
- Authorizer
Set - A set of
IDynamicAuthorizerinstances collected from the DI container. - Compression
Config - Compression configuration.
- Compression
Middleware - Middleware that compresses response bodies with gzip when the client
supports it (via
Accept-Encoding: gzip) and the response exceedsmin_sizebytes. - Controller
Endpoint - Endpoint for controller-based methods.
- Cors
Config - CORS configuration loaded from appsettings.json.
- Cors
Middleware - Built-in CORS middleware.
- Cors
Section - CORS (Cross-Origin Resource Sharing) section.
- Distributed
Cache Entry Options - Field
Error - Handler
Cache - Runtime registry of compiled handler registrations.
- Handler
Entry - A single compiled handler entry in the registry.
- Handler
Registration - Handler registration collected at compile time.
Each
#[handler]annotation submits one of these to inventory. - Health
Check Entry - A single health check entry in a registry snapshot.
- Health
Check Registry - Health
Status - Host
- Host
AppBuilder - Host
Builder - Http
Context - Concrete implementation of IHttpContext wrapping a hyper request and response.
- Http
Request - Concrete implementation of IHttpRequest.
- Http
Response - Concrete implementation of IHttpResponse.
- Http
Status - Common HTTP status codes.
- JwtAuth
- JWT-based authentication handler.
- JwtClaims
- Claims extracted from a JWT token.
- JwtSection
- JWT authentication section.
- Mediator
- Default implementation of IMediator.
- Memory
Cache - Metrics
Section - HTTP request metrics (
GET /metricsPrometheus text when enabled). - Middleware
Pipeline - Paged
Request - Paged
Response - Param
Meta - Metadata about a request parameter for OpenAPI generation.
- Problem
Details - Rate
Limit Middleware - Rate
Limit Section - Per-IP rate limiting (token bucket).
- Rate
Limiter - Inner rate-limiting state shared behind a
Mutex. - Request
Context - Scoped operator identity from JWT
sub, set by the HTTP dispatch pipeline. - Request
Endpoint - Endpoint that wraps a boxed async handler.
- Request
IdMiddleware - Generates a UUID v4 request ID on each request and injects it into the response.
- Request
Tracing - Resource
Authorization - Authorization policy that maps route patterns to allowed roles and permissions.
- Response
Data - Response data produced by a dispatch function.
- Route
Dispatch - A dispatch function registered at compile time via the endpoint macros.
- Route
Entry - A route entry registered at compile time via
#[endpoint](or its shortcuts#[get]/#[post]/…). - Route
Meta - Route metadata: method + path pattern.
- Router
- Matchit-based router.
- Security
Headers Middleware - Middleware that adds a standard set of security headers to every response.
- Server
- A fully built server that owns its runtime lifecycle.
- Server
Handle - Handle for a running server, allowing programmatic graceful shutdown.
- SpaMiddleware
- SPA static file middleware.
- Static
Html Endpoint - Endpoint that serves a static HTML payload.
- Static
Json Endpoint - Endpoint that serves a static JSON payload.
- Timing
Middleware - Records a request counter via the
afterhook. - TlsSection
- TLS (Transport Layer Security) section.
Enums§
- AppMode
- Controls how the framework behaves at startup and at runtime.
- Cache
Error - Error
- Framework-wide error type.
- Http
Method - HTTP methods supported by the framework.
Constants§
- APIUI_
HTML - The embedded HTML for the API docs UI.
Traits§
- Distributed
Cache Extensions - From
Http Context - Trait for constructing a request struct from the HTTP context.
- IApp
Options - Application options — binds to a section of appsettings.json.
- IAuthentication
Handler - Authentication scheme interface.
- IAuthorization
Policy - Authorization policy that checks whether an authenticated user can access a given resource.
- IClaims
- Claims extracted from an authentication token (JWT, etc.).
- IClaims
Carrier - Blanket trait that enables claims injection on request structs.
- IClaims
Ext - Extension trait that adds claims storage to an
IHttpContext. - IDistributed
Cache - IDynamic
Authorizer - Dynamic authorizer interface — pluggable authorization for protected routes.
- IEndpoint
- An endpoint handler is the terminal component in the middleware pipeline.
- IEvent
Handler - Handles a single
IEventRequest, performing side effects. - IEvent
Request - Marker trait for an event (notification) that does not produce a response.
- IHost
- The web host that binds to an address and starts serving HTTP requests.
- IHosted
Service - Background service that is started when the host starts and stopped when the host performs a graceful shutdown.
- IHttp
Context - HTTP context encapsulating the request, response, and service provider for the duration of a single HTTP request.
- IHttp
Request - HTTP request abstraction.
- IHttp
Response - HTTP response abstraction.
- IMediator
- The mediator dispatches requests to their handlers and publishes events to all registered handlers.
- IMiddleware
- Middleware component in the HTTP request pipeline.
- IPipeline
Behavior - Pipeline behavior that wraps around request handling.
- IRequest
- Marker trait for a request (command or query) carrying a structured response
TResponse. - IRequest
Handler - Handles a single
IRequest<R>, producing its associated responseR. - IRouter
- Router that matches incoming HTTP requests to registered endpoints.
- IService
Collection Ext - Extension methods for
rust_dix::ServiceCollectionto enable framework-level service registration patterns. - Scope
Factory - 工厂 trait:创建独立 scope。可注入 singleton 服务按需创建 scope。
Functions§
- app_
base - 解析应用基准目录。优先级见模块文档。
- bind_
config - Bind a section of the config JSON to a deserializable type.
- bind_
root - Bind the entire config JSON to a type (for root-level deserialization).
- build_
pipeline_ chain - Build a chain of pipeline behaviors wrapping a terminal handler.
- collect_
authorizers - Result from collecting
IDynamicAuthorizerinstances from DI.Nonemeans no authorizers are registered (pass-through mode). - compress_
gzip - Compress a byte buffer using gzip at the given compression level (0-9).
- format_
route_ diagnostics - Human-readable route/handler diagnostic report (no tracing dependency).
- generate_
openapi_ spec - Generate an OpenAPI 3.0.3 specification from registered routes.
- global_
provider - Get the global service provider. Used by
#[handler]factories when the handler struct has#[inject_attr]for DI-based construction. - init_
jwt_ secret - Initialize the global JWT encoding secret from the configured secret.
This is called automatically by
.add_authentication()on theHostBuilder, but can also be called manually if needed. - is_
mediator_ active - jwt_
middleware - Create a JWT authentication middleware from an authentication handler.
- jwt_
secret - Retrieve the global JWT encoding secret previously set via
init_jwt_secret. - load_
appsettings - Load the merged appsettings JSON (base + environment overlay + env overrides).
- log_
startup_ diagnostics - Log route table and warn on orphan routes/handlers.
- looks_
like_ app_ base - 判断给定目录是否为「应用基准目录」(存在
appsettings.json)。 - orphan_
handlers - Request types registered via
#[handler]without a matching route. - orphan_
routes - Request types with a route but no registered handler.
- read_
json_ body - Helper: read JSON from the request body.
- resource_
auth_ middleware - Create a resource-based authorization middleware.
- route_
snapshots - Collect all inventory routes and whether a matching
#[handler]exists. - set_
global_ provider - Set the global service provider. Called once at
Host::build()time. - should_
scan_ endpoints - write_
json_ response - Helper: build a JSON response by serializing a value and writing it.
Type Aliases§
- Boxed
Next Fn - Type-erased continuation function for pipeline behaviors.
- Boxed
Pipeline Future - Boxed future returned by a pipeline behavior step.
- Handler
Fn - Boxed final handler function type.
- Handler
Registry - Preferred name for
HandlerCache— emphasizes registry semantics over caching. - Health
Check Fn - Json
- Type alias for JSON responses in controller methods.
- Result
- Shorthand for Result<T, Error>.
Attribute Macros§
- async_
trait - authorize
- Declares authorization requirements on a route.
- claims
- Marks a request struct as carrying authentication claims.
- delete
- Shortcut: registers an IRequest impl at DELETE /path.
- endpoint
- Full form: marks an IRequest impl with HTTP method and route path.
- from_
body - Marks a field or parameter as deserialized from the JSON request body.
- from_
query - Marks a field or parameter as extracted from the query string.
- from_
route - Marks a field or parameter as extracted from the route path.
- get
- Shortcut: registers an IRequest impl at GET /path.
- handler
- Auto-registers an IRequestHandler implementation at compile time via inventory.
- inject
- module
- post
- Shortcut: registers an IRequest impl at POST /path.
- put
- Shortcut: registers an IRequest impl at PUT /path.