Expand description
§Blazingly
Blazingly is an operation-first Rust API framework: handler signatures and Rust models define extraction, validation, typed responses, OpenAPI, and generated documentation — and the same operation model natively defines MCP tools, resources, and prompts, not a reconstruction from OpenAPI.
This crate is the facade. cargo add blazingly re-exports the framework
crates under one name and one prelude; each underlying crate
(blazingly-core, blazingly-openapi, blazingly-mcp, and the rest) is an
ordinary library usable on its own, and the facade adds the curated surface,
the feature wiring, and the macros. MSRV is Rust 1.88. tokio, hyper, and
axum are banned from the dependency graph at any depth and CI enforces it.
§What you get
- FastAPI-style handlers:
#[get]/#[post]/… on plain functions,#[api_model]validated models,#[api_error]stable typed errors; - compiled dependency injection (
#[provider],Depends<T>, withPath/Query/Header/Cookieinputs beside them) and nested, mountablePluginscopes with lifecycle hooks; - custom extraction through
Extract<T>over the publicFromInvocationtrait, andExtract<RequestParts>for the request line and peer address; - runtime-neutral
Request,Response, compiledRouter, and an in-memoryTestApp; - deterministic OpenAPI 3.1 / JSON Schema 2020-12 with precompiled
/openapi.jsonand Scalar/Swagger UI mounts; - native MCP: the same typed operations served over JSON-RPC, Streamable HTTP, and supervised stdio, with confirmation and output-exposure policy;
- generated API/AI Markdown bundles, project scaffolds, deployment files, and versioned operation contracts with compatibility reports;
- middleware (CORS, compression, rate limits, trusted host/proxy), security
verifiers (JWT, OAuth2 bearer, API key, signed sessions), and
observability (request IDs, W3C trace context,
tracing, Prometheus); - an opt-in Tokio-free Compio native HTTP/1 server with rustls TLS, SSE, and WebSocket upgrades.
New in 0.2: request-aware providers (a #[provider] takes Path/Query/
Header/Cookie inputs, folded into the consuming operation’s contract
exactly once), Plugin::mount("/v1") and with_id_namespace("v1") for serving
one module under two prefixes with distinct operation identities, custom
extraction through Extract<T> over the public FromInvocation trait, and
value-type constraints that survive nesting — a #[min_length] on a newtype
now reaches the items schema of a Vec<T> that uses it, at any depth. The
full list is in the changelog.
One caveat worth knowing early: a synchronous handler runs inline on the worker
that accepted the request and is never moved to the blocking pool. Anything
that genuinely blocks must call run_blocking.
§Features
deploy, docs, mcp, middleware, observability, openapi,
realtime, security, and validation are enabled by default. Opt-in:
native, native-tls, native-http2 (experimental), mcp-stdio,
database, queue, templates, and observability-otel.
cargo check -p blazingly --no-default-features verifies the minimal surface:
contract, core, DI, executor, HTTP, macros, and blazingly-json. It does not
drop the OpenAPI projection from the build — blazingly-http serves
/openapi.json and depends on blazingly-openapi unconditionally, so the
openapi feature gates the re-export rather than the compilation.
§Example
use blazingly::prelude::*;
#[api_model]
struct CreateUser {
#[email]
email: String,
}
#[api_model]
struct UserView {
id: u64,
email: String,
}
#[post("/users", id = "users.create", summary = "Create a user")]
#[mcp::tool(name = "create_user", risk = "write")]
async fn create_user(Json(input): Json<CreateUser>) -> Created<UserView> {
Created(UserView {
id: 1,
email: input.email,
})
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = ExecutableApp::new(routes![create_user])?;
// The same typed operation, projected without a server:
let openapi = blazingly::openapi::to_value(app.definition());
let agent_docs = blazingly::docs::mcp_markdown(app.definition());
println!("{openapi}\n{agent_docs}");
Ok(())
}TestApp exercises the same application entirely in memory; the opt-in
native feature serves it over the Tokio-free HTTP/1 socket server.
§Links
- Getting started — install, a first application, validation, DI, OpenAPI, and MCP
- API documentation
- Changelog
- Stability and SemVer — what pre-1.0 does and does not promise
- Repository — the
framework-internal documentation lives in
docs/
Re-exports§
pub use blazingly_database as database;pub use blazingly_deploy as deploy;pub use blazingly_docs as docs;pub use blazingly_http as http;pub use blazingly_json as json;pub use blazingly_middleware as middleware;pub use blazingly_observability as observability;pub use blazingly_openapi as openapi;pub use blazingly_queue as queue;pub use blazingly_realtime as realtime;pub use blazingly_security as security_runtime;pub use blazingly_templates as templates;pub use blazingly_validation as validation;
Modules§
Macros§
- descriptors
- routes
- Collects annotated handlers into the operation list an application is built from.
Structs§
- Accepted
- A successful HTTP 202 response.
- Agent
Policy - Protocol-neutral metadata used by MCP and other agent transports.
- App
- Builder for an application description.
- AppDefinition
- A validated, deterministic application description.
- Background
- A typed response carrying work that starts after its wire body is sent.
- Background
Task - One runtime-neutral task that begins after the response body is written.
- Background
Task Error - A failure produced by work scheduled after an HTTP response is sent.
- Blocking
Future - Future resolved by a bounded blocking worker.
- Blocking
Pool - A bounded process-wide pool used only by explicitly synchronous handlers.
- Blocking
Pool Config - Capacity and worker count for synchronous blocking handlers.
- Body
Stream Error - One failure produced while an HTTP response body is being streamed.
- Cancellation
Token - Runtime-neutral cooperative cancellation shared by adapters and operation execution.
- Compatibility
- Entry point for semantic contract comparison.
- Compatibility
Change - One deterministic compatibility finding.
- Compatibility
Report - Semantic compatibility report between two versions of one operation.
- Connection
Info - Normalized transport values readable by a handler extractor.
- Contract
Fingerprint - Stable SHA-256 identity of one canonical operation contract.
- Contract
Format Version - Version of the canonical Blazingly contract format.
- Cookie
- A typed HTTP cookie argument.
- Created
- A successful HTTP 201 response.
- Dependency
Descriptor - A typed dependency declared by an operation handler.
- Dependency
Key - Runtime identity of a typed dependency.
- Dependency
Request - A dependency required by one operation handler.
- Depends
- A resolved typed dependency passed to a handler or provider.
- Executable
App - A validated executable operation graph.
- Executable
Operation - A handler plus the operation descriptor shared by HTTP and MCP.
- Extension
- Typed request-local value installed by transport middleware.
- Extract
- Explicitly asks the operation macro to extract
Tfrom the invocation. - Field
Descriptor - One field in an API model.
- Field
Violation - One typed model-validation failure.
- File
- A typed uploaded file argument.
- Form
- A typed
application/x-www-form-urlencodedrequest body. - Header
- A typed HTTP header argument.
- Hook
Context - Runtime-neutral metadata passed to compiled plugin hooks.
- Hook
Outcome - A body-free result summary passed to
on_responsehooks. - HttpApp
- An owned, runtime-neutral HTTP application compiled from the operation graph.
- Http
Binding - The HTTP projection of a protocol-neutral operation contract.
- Http
Request Context - Mutable, request-local context shared by runtime-neutral HTTP middleware.
- Http
Upgrade - A validated HTTP protocol switch plus its post-handshake session handler.
- Input
Descriptor - One typed operation argument and its HTTP extraction source.
- Input
Rejection - A stable client-visible failure produced while extracting an argument.
- Invalid
Operation Id - An invalid operation identity.
- Invocation
Control - Adapter-supplied cancellation and timeout signals for one invocation.
- Json
- A typed JSON request body.
- McpTool
Descriptor - MCP tool semantics declared alongside an operation.
- Model
Descriptor - A complete model used by validation,
OpenAPI, MCP, and Markdown. - Multipart
- A typed
multipart/form-datarequest body. - Multipart
Field - One part of a streamed
multipart/form-databody. - Multipart
Part Headers - The
Content-Dispositionmetadata of one multipart part. - Multipart
Stream - A
multipart/form-datarequest body read part by part, chunk by chunk. - NoContent
- A successful HTTP 204 response without a body.
- Operation
Contract - The protocol-neutral semantic contract for one operation.
- Operation
Descriptor - A protocol-neutral operation paired with its HTTP projection.
- Operation
Failure - A typed domain failure shared by HTTP and MCP projections.
- Operation
Id - A stable, human-readable operation identity such as
users.create. - Path
- A typed path argument.
- Plugin
- A lexical provider scope containing operations and nested plugins.
- Prepared
Json - A JSON response body the operation encoded itself.
- Provider
- A typed dependency provider registered in a plugin scope.
- Query
- Typed URL query arguments.
- Request
- A runtime-neutral HTTP request.
- Request
Parts - An owned snapshot of the raw request parts, taken before the handler runs.
- Request
Provider - A provider together with the request inputs it declared.
- Resolved
Dependencies - Slot-based dependency values visible to one operation handler.
- Response
- A runtime-neutral HTTP response.
- Response
Build Error - A response construction failure that must be redacted by transports.
- Response
Descriptor - A single successful or error response declared by an operation.
- Response
Header - A response header emitted without transport-specific dependencies.
- Route
Match - A compiled route match with its direct operation slot and path captures.
- Router
- A runtime-neutral router compiled once from the operation graph.
- Security
Requirement - Security scheme and scopes required by one operation.
- Security
Scheme Descriptor - Named security scheme registered by an application.
- Status
- Overrides the successful status of another typed response.
- Streaming
Body - Typed streaming HTTP response body.
- TestApp
- An in-memory borrowed HTTP adapter over the shared executable operation graph.
- Test
Overrides - Typed provider replacements applied only while compiling a test app.
- Type
Descriptor - The type identity and schema captured by the Rust frontend.
- Upgrade
IoError - A transport error after an HTTP connection has switched protocols.
- Upload
Body - Pull-based request body with adapter-enforced transport limits.
- Upload
File - Runtime-neutral buffered upload metadata.
- Validation
Errors - All model-validation failures collected in one pass.
- With
Headers - Adds response headers without changing the typed response body.
Enums§
- Blocking
Error - Failure to schedule or execute a synchronous blocking handler.
- Build
Error - An invalid application graph.
- Collect
Body Error - Failure while deliberately buffering an HTTP response stream.
- Compatibility
Impact - Compatibility impact of one semantic contract change.
- Confirmation
- Whether an agent must ask for confirmation before invoking an operation.
- Dependency
Error - A stable request rejection or an internal dependency failure.
- Dependency
Lifetime - The lifetime of a dependency provider.
- Executable
Build Error - An application-definition or dependency-compilation failure.
- Execution
Outcome - The protocol-neutral result of executing one operation.
- Field
Metadata - Field metadata carried inside
ValidationRule::Custom. - Hook
Outcome Kind - Stable result classes visible to plugin response hooks.
- Http
Method - HTTP methods supported by the operation frontend.
- Input
Source - The transport-neutral source of one operation argument.
- Invocation
Abort - Reason a controlled invocation stopped before completion.
- Invocation
Input - Transport-neutral values supplied to typed operation extractors.
- Multipart
Error - A failure produced while reading a
multipart/form-datarequest body. - Operation
Risk - Agent-visible risk associated with invoking an operation.
- Output
Exposure - How much operation output may be exposed to an agent.
- Route
Error - A router miss that distinguishes an unknown path from a wrong method.
- Schema
Kind - Transport-independent JSON shape.
- Security
Location - HTTP location used by an API-key security scheme.
- Security
Scheme Kind - Transport-independent description of an application security scheme.
- Validation
Rule - Validation generated as native Rust code by
#[api_model].
Constants§
- CURRENT_
CONTRACT_ FORMAT_ VERSION - The current canonical contract encoding version.
- MAX_
MULTIPART_ HEADER_ BYTES - Largest header block accepted for one
multipart/form-datapart. - MAX_
MULTIPART_ PARTS - Largest number of parts accepted in one
multipart/form-databody.
Traits§
- ApiConstrained
- A value type whose field rules are declared once and reused by name.
- ApiError
- A user-declared operation error with stable transport semantics.
- ApiModel
- A model that can describe and validate itself without runtime reflection.
- ApiSchema
- A Rust type that can participate in an operation schema.
- Background
Ext - Ergonomic after-response task decoration.
- Body
Stream - Runtime-neutral, pull-based response byte stream.
- From
Invocation - Decodes one typed handler argument from an invocation.
- Http
Middleware - Synchronous middleware interception points shared by every HTTP adapter.
- Http
Request Parts - Borrowed HTTP request values used by the compiled executor.
- Http
Request View - Borrowed request access used by in-memory and native HTTP adapters.
- Operation
Output - A typed handler result that can become a shared operation outcome.
- Response
Ext - Ergonomic response decoration shared by typed success responses.
- Upgraded
Io
Functions§
- blocking_
error_ outcome - install_
global_ blocking_ pool - Installs the process-wide blocking pool before the first sync invocation.
- merge_
field_ validation_ errors - Records a field validator’s violations under the field it was declared on.
- merge_
validation_ errors - Prefixes nested model violations while preserving stable codes/messages.
- record_
response_ size - Records the encoded size of a body of shape
T. - response_
size_ hint - Returns the capacity to reserve for the next body of shape
T. - run_
blocking - Schedules owned synchronous work without blocking an async worker.
Type Aliases§
- Background
Future - Operation
Future - Provider
Input Decoder - Decodes one provider-declared request input into an erased slot value.
- Upgrade
Future - Upgrade
Handler - Upgrade
Read Future - Runtime-neutral byte I/O owned after an HTTP protocol upgrade.
- Upgrade
Write Future
Attribute Macros§
- api_
error - Declares a stable domain error as an enum.
- api_
model - Declares an API model.
- connect
- Declares a
CONNECToperation. Seegetfor the argument form. - delete
- Declares a
DELETEoperation. Seegetfor the argument form. - get
- Declares a
GEToperation. - head
- Declares a
HEADoperation. Seegetfor the argument form. - operation
- Defines an operation using an explicit HTTP method.
- options
- Declares an
OPTIONSoperation. Seegetfor the argument form. - patch
- Declares a
PATCHoperation. Seegetfor the argument form. - post
- Declares a
POSToperation. Seegetfor the argument form. - provider
- Turns a typed factory function into a compiled DI provider declaration.
- put
- Declares a
PUToperation. Seegetfor the argument form. - security
- Requires a registered security scheme, and optionally scopes, for an operation.
- trace
- Declares a
TRACEoperation. Seegetfor the argument form.