Skip to main content

Crate vantus

Crate vantus 

Source
Expand description

Public entrypoint for the Vantus framework.

Most application code only needs the re-exports from this file: HostBuilder for bootstrapping, #[module] / #[controller] for structure, and the typed request extractors for handlers.

use vantus::{HostBuilder, RequestContext, Response, module};

#[derive(Clone)]
struct HealthModule;

#[module]
impl HealthModule {
    #[vantus::get("/health")]
    fn health(&self, ctx: RequestContext) -> Response {
        Response::json_value(serde_json::json!({
            "service": ctx.app_config().service_name,
            "status": "ok",
        }))
    }
}

fn main() {
    let mut builder = HostBuilder::new();
    builder.compose_with_config(|_configuration, _app, context| {
        context.module(HealthModule);
        Ok(())
    });
    builder.build().run_blocking();
}

Structs§

AppConfig
Built-in framework configuration model.
ApplicationHost
AtomicIdGenerator
Cheap monotonic ID generator backed by an atomic counter.
BodyBytes
Zero-copy request body bytes.
CliFeatureDefaults
Default states for first-party modules when the CLI does not override them.
Configuration
Layered key-value configuration store used by the framework.
ConfigurationBuilder
Builder for layered configuration loading.
GlobalRateLimiter
Header
Extracts and parses a named request header.
HealthModule
HostBuilder
Fluent application bootstrap API.
HostContext
Runtime context passed to lifecycle hooks.
HttpError
IdentityState
Typed request identity inserted by middleware.
InfoModule
JsonBody
JSON request body extractor.
ObservabilityModule
PanicRecovery
Path
Extracts a named path segment from the matched route.
Query
Extracts a named query-string value.
QueryMap
Provides access to the full query map.
ReadinessCheck
ReadinessRegistry
Request
RequestContext
Per-request framework context passed to handlers and middleware.
RequestId
RequestLogEvent
Structured request log payload emitted by framework middleware.
RequestLogger
RequestState
Typed request-local state inserted by middleware.
Response
RuntimeSnapshot
RuntimeState
SecurityHeaders
ServerCli
First-party CLI bootstrap for Vantus applications.
ServerConfig
Parsed server settings from AppConfig.
ServerHandle
ServerOptions
Runtime-ready server settings after validation.
StdIoLogSink
Default sink that writes JSON to stdout/stderr without installing tracing globals.
TextBody
UTF-8 text body extractor.
UuidIdGenerator
UUID-backed generator for globally unique identifiers.
WebPlatformModule

Enums§

CliError
ConfigError
Errors produced while loading or binding configuration.
ExtractorError
FrameworkError
HostBuildError
HostError
IdGeneratorKind
Shared ID generator choices exposed by the CLI.
LogLevel
Coarse log level used by the framework’s default sink abstraction.
Method
MiddlewareStage
ParseError
RuntimeMode
Runtime preset applied by the CLI.
ServerProtocol
Server protocol mode selected from configuration.

Traits§

Controller
Marker trait for route-focused types.
FromConfig
Projects a sub-config from an already bound root config.
FromConfiguration
Manual configuration binding contract.
FromRequest
Generic extraction contract for handler parameters.
IdGenerator
Shared service contract for generating application identifiers.
Identity
Marker trait for request-scoped caller identity payloads inserted by middleware.
IntoHandlerResult
Compatibility shim for the older macro return-conversion name.
IntoResponse
Converts typed handler return values into the framework response model.
LogSink
Destination for text and structured request logs emitted by the framework.
Middleware
Module
The core application building block in Vantus.
NamedFromRequest
Named extraction contract used by Path<T> and Query<T>.
NamedOptionalFromRequest
Optional named extraction contract used by Option<Query<T>> and Option<Header<T>>.
OptionalFromRequest
Optional extraction contract used for safe request-derived inputs.
ReadinessContributor
RuntimeModule
Optional lifecycle hooks for long-lived application modules.

Functions§

emit_default_log
redact_headers
Redacts sensitive header values before they are copied into logs.
sanitize_log_message
Best-effort secret scrubbing for ad-hoc log messages.
sanitize_path_for_logs
Scrubs path segments that look like identifiers before logging.

Type Aliases§

MiddlewareFuture

Attribute Macros§

async_trait
controller
Attribute macros used to define route-bearing modules and controllers.
delete
Attribute macros used to define route-bearing modules and controllers.
get
Attribute macros used to define route-bearing modules and controllers.
head
Attribute macros used to define route-bearing modules and controllers.
middleware
Attribute macros used to define route-bearing modules and controllers.
module
Attribute macros used to define route-bearing modules and controllers.
options
Attribute macros used to define route-bearing modules and controllers.
patch
Attribute macros used to define route-bearing modules and controllers.
post
Attribute macros used to define route-bearing modules and controllers.
put
Attribute macros used to define route-bearing modules and controllers.