Skip to main content

a3s_boot/
lib.rs

1//! Progressive Rust web framework primitives for A3S.
2//!
3//! `a3s-boot` is inspired by Nest.js, but keeps the Rust core explicit:
4//! modules organize the graph, providers live in a typed container, controllers
5//! group routes, request pipeline hooks are framework-neutral, and HTTP serving
6//! is delegated to replaceable adapters.
7
8use std::future::Future;
9use std::net::SocketAddr;
10use std::pin::Pin;
11
12mod adapters;
13mod app;
14mod error;
15mod http;
16mod module;
17mod percent;
18mod pipeline;
19mod provider;
20mod routing;
21
22#[cfg(feature = "macros")]
23pub use a3s_boot_macros::{
24    controller, delete, delete_json, get, get_json, head, injectable, options, patch, patch_json,
25    post, post_json, put, put_json, sse,
26};
27#[cfg(feature = "axum")]
28pub use adapters::AxumAdapter;
29pub use app::{BootApplication, BootApplicationBuilder, RouteMatch};
30pub use error::BootError;
31pub use http::{BootRequest, BootResponse, HttpMethod, SseEvent, SseStream};
32pub use module::Module;
33pub use pipeline::{ExceptionFilter, ExecutionContext, Guard, Interceptor, Pipe};
34pub use provider::{ModuleRef, ProviderDefinition, ProviderToken};
35pub use routing::{ControllerDefinition, RouteDefinition, RouteHandler};
36
37/// Result type used by A3S Boot.
38pub type Result<T> = std::result::Result<T, BootError>;
39
40/// Boxed future used by adapter traits.
41pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
42
43/// Adapter that turns a Boot application into a concrete HTTP server/router.
44pub trait HttpAdapter {
45    type Output;
46
47    fn build(&self, app: BootApplication) -> Result<Self::Output>;
48
49    fn serve(&self, app: BootApplication, addr: SocketAddr) -> BoxFuture<'static, Result<()>>;
50}