1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Auto-route registration using linkme distributed slices
//!
//! This module enables zero-config route registration. Routes decorated with
//! `#[rustapi::get]`, `#[rustapi::post]`, etc. are automatically collected at link-time.
//!
//! # How It Works
//!
//! When you use `#[rustapi::get("/path")]` or similar macros, they generate a
//! static registration that adds the route factory function to a distributed slice.
//! At runtime, `RustApi::auto()` collects all these routes and registers them.
//!
//! # Example
//!
//! ```rust,ignore
//! use rustapi_rs::prelude::*;
//!
//! #[rustapi::get("/users")]
//! async fn list_users() -> Json<Vec<User>> {
//! Json(vec![])
//! }
//!
//! #[rustapi::post("/users")]
//! async fn create_user(Json(body): Json<CreateUser>) -> Created<User> {
//! // ...
//! }
//!
//! #[rustapi::main]
//! async fn main() -> Result<()> {
//! // Routes are auto-registered, no need for manual .mount() calls!
//! RustApi::auto()
//! .run("0.0.0.0:8080")
//! .await
//! }
//! ```
use crateRoute;
use distributed_slice;
/// Distributed slice containing all auto-registered route factory functions.
///
/// Each element is a function that returns a [`Route`] when called.
/// The macro `#[rustapi::get]`, `#[rustapi::post]`, etc. automatically
/// add entries to this slice at compile/link time.
pub static AUTO_ROUTES: ;
/// Collect all auto-registered routes.
///
/// This function iterates over the distributed slice and calls each
/// route factory function to produce the actual [`Route`] instances.
///
/// # Returns
///
/// A vector containing all routes that were registered using the
/// `#[rustapi::get]`, `#[rustapi::post]`, etc. macros.
///
/// # Example
///
/// ```rust,ignore
/// let routes = collect_auto_routes();
/// println!("Found {} auto-registered routes", routes.len());
/// ```
/// Get the count of auto-registered routes without collecting them.
///
/// Useful for debugging and logging.