Skip to main content

fastapi_router/
lib.rs

1//! Trie-based HTTP router.
2//!
3//! This crate provides a high-performance radix trie router optimized
4//! for the fastapi_rust framework.
5//!
6//! # Features
7//!
8//! - Radix trie for fast lookups
9//! - Path parameter extraction (`/items/{id}`)
10//! - Type-safe path converters
11//! - Static route optimization
12//!
13//! # Role In The System
14//!
15//! `fastapi-router` is responsible for matching incoming paths to handlers and
16//! extracting typed parameters. `fastapi-core` uses it for request dispatch,
17//! while `fastapi-openapi` reads its parameter metadata when generating specs.
18//! Keeping the router isolated allows the rest of the framework to stay focused
19//! on request semantics rather than path matching internals.
20
21#![warn(unsafe_code)]
22// Pedantic clippy lints allowed (style suggestions, not correctness issues)
23#![allow(clippy::needless_lifetimes)]
24#![allow(clippy::elidable_lifetime_names)]
25#![allow(clippy::trivially_copy_pass_by_ref)]
26#![allow(clippy::cast_ptr_alignment)]
27#![allow(clippy::ptr_as_ptr)]
28#![allow(clippy::borrow_as_ptr)]
29#![allow(clippy::match_same_arms)]
30#![allow(clippy::manual_let_else)]
31#![allow(clippy::uninlined_format_args)]
32#![allow(clippy::single_match_else)]
33#![allow(clippy::needless_pass_by_value)]
34#![allow(clippy::must_use_candidate)]
35#![allow(clippy::missing_fields_in_debug)]
36#![allow(clippy::needless_borrow)]
37#![allow(clippy::ref_as_ptr)]
38#![allow(clippy::used_underscore_binding)]
39#![allow(clippy::too_many_lines)]
40#![allow(clippy::match_wildcard_for_single_variants)]
41#![allow(clippy::needless_borrows_for_generic_args)]
42
43mod r#match;
44mod registry;
45mod trie;
46
47pub use r#match::{AllowedMethods, RouteLookup, RouteMatch};
48pub use registry::{RouteRegistration, registered_routes};
49pub use trie::{
50    ConversionError, Converter, InvalidRouteError, ParamInfo, ParamValue, Route, RouteAddError,
51    RouteConflictError, RouteResponse, RouteSecurityRequirement, Router, extract_path_params,
52};