mars-server · api
Public declarations and documentation for mars-server::api.
Package: mars-server · Workspace version: 0.1.0 · Module: api
This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.
api::rest
Router assembly and shared application state.
This module wires together all REST and WebSocket handlers into a single
[axum::Router] and defines the [AppState] shared across all handlers.
pub mod rest;Source line: 6.
api::websocket
pub mod websocket;Source line: 7.
api::MAX_QUERY_BODY_BYTES
Maximum buffered JSON body accepted by every public query endpoint.
This accommodates the protocol's maximum structured query while bounding allocation before deserialization or any federated fanout.
pub const MAX_QUERY_BODY_BYTES: usize;Source line: 27.
api::AppState
Application state shared across all handlers.
Stored in an [Arc] and injected into handlers via axum's State extractor.
pub struct AppState {
/// Storage backend for entries, bonds, events, and peers.
pub store: Arc<dyn EntryStore>,
/// Server configuration.
pub config: ServerConfig,
/// Validation pipeline for incoming entries.
pub validation: ValidationPipeline,
/// Provider-neutral bond lookup/provisioning port.
pub bond_port: Arc<dyn crate::bond::BondPort>,
/// Discovery engine for MARS-QL queries.
pub discovery: Arc<DiscoveryEngine>,
/// Signed inbound federation service, present only when federation is
/// fully configured.
pub federation_service: Option<Arc<crate::federation::FederationService>>,
/// Optional bounded local-plus-peer discovery coordinator.
pub federated_discovery: Option<Arc<crate::federation::FederatedDiscoveryCoordinator>>,
/// Rate limiter for read endpoints.
pub read_limiter: RateLimiter,
/// Rate limiter for write endpoints.
pub write_limiter: RateLimiter,
/// Rate limiter for query/discovery endpoints.
pub query_limiter: RateLimiter,
/// Rate limiter for authentication bootstrap and session endpoints.
pub auth_limiter: RateLimiter,
/// Rate limiter for WebSocket upgrade admission.
pub websocket_limiter: RateLimiter,
/// Whether a concrete [`crate::anchor::AnchorPort`] is registered.
///
/// Production wires the Sigil SDK adapter only after authenticated deep
/// readiness succeeds.
pub anchor_adapter_registered: bool,
/// Process-local anchor worker supervisor health.
pub anchor_worker_health: crate::anchor::AnchorWorkerHealth,
/// Bounded live dependency probe for Sigil GAL and anchor RPC readiness.
pub anchor_readiness: Option<Arc<dyn crate::anchor::AnchorReadinessPort>>,
/// SIWS authentication state — challenge store, session store, and
/// registered provider adapters. The domain and capability middleware are
/// always available; concrete SIWS verification is feature-gated.
pub auth: Arc<crate::auth::AuthState>
}Source line: 32.
api::build_router
Build the complete axum Router with all REST and WebSocket endpoints.
Mounts all endpoints under /v1/ per MARS Specification Appendix D.
Mutation routes and federated discovery declare their required MARS capability and resolve a provider-neutral Principal before invoking handlers. Public reads, local queries, authentication, and WebSocket admission use separate per-client buckets; deep health additionally requires operator capability.
pub fn build_router(state: Arc<AppState>) -> Router;Source line: 109.
Source provenance
Source: mars-server/src/api/mod.rs · SHA-256 28838016278b0fd7a926ef006bea8e975c2d71861fdfb6b4d054ee037bbf6b3b. Package overview.