httpageboy/
lib.rs

1pub mod core;
2
3// Common re-exports (always available)
4pub use crate::core::{request_type::Rt, response::Response, status_code::StatusCode, test_utils};
5
6// Feature-gated re-exports (exist only when any handler feature is enabled)
7#[cfg(any(
8  feature = "sync",
9  feature = "async_tokio",
10  feature = "async_std",
11  feature = "async_smol"
12))]
13pub use crate::core::{handler::Handler, request::Request, request_handler::Rh};
14
15pub mod runtime {
16  #[cfg(feature = "sync")]
17  pub mod sync {
18    pub mod server;
19    pub mod threadpool;
20  }
21
22  #[cfg(any(feature = "async_tokio", feature = "async_smol", feature = "async_std"))]
23  pub mod r#async {
24    #[cfg(feature = "async_std")]
25    pub mod async_std;
26    pub mod shared;
27    #[cfg(feature = "async_smol")]
28    pub mod smol;
29    #[cfg(feature = "async_tokio")]
30    pub mod tokio;
31  }
32
33  pub mod shared;
34}
35
36// Server export selection
37#[cfg(feature = "sync")]
38pub use runtime::sync::server::Server;
39
40#[cfg(all(not(feature = "sync"), feature = "async_tokio"))]
41pub use runtime::r#async::tokio::Server;
42
43#[cfg(all(not(feature = "sync"), not(feature = "async_tokio"), feature = "async_smol"))]
44pub use runtime::r#async::smol::Server;
45
46#[cfg(all(
47  not(feature = "sync"),
48  not(feature = "async_tokio"),
49  not(feature = "async_smol"),
50  feature = "async_std"
51))]
52pub use runtime::r#async::async_std::Server;
53
54// Fallback dummy server if no feature is active
55#[cfg(all(
56  not(feature = "sync"),
57  not(feature = "async_tokio"),
58  not(feature = "async_smol"),
59  not(feature = "async_std")
60))]
61pub struct Server;
62
63#[cfg(all(
64  not(feature = "sync"),
65  not(feature = "async_tokio"),
66  not(feature = "async_smol"),
67  not(feature = "async_std")
68))]
69impl Server {
70  pub fn new() -> Self {
71    eprintln!(
72      "\n❌ No feature is active.\n\nActivate a feature when compiling:\n\n    cargo run --features sync\n    cargo run --features async_tokio\n    cargo run --features async_std\n    cargo run --features async_smol\n"
73    );
74    panic!("No feature selected.");
75  }
76}