1pub mod additions;
8#[cfg_attr(docsrs, doc(cfg(feature = "clients")))]
9#[cfg(feature = "clients")]
10pub mod client;
11pub mod errors;
12mod ext_map;
13pub mod handlers;
14pub mod models;
15#[cfg_attr(docsrs, doc(cfg(feature = "servers")))]
16#[cfg(feature = "servers")]
17pub mod server;
18
19pub use ext_map::Extensions;
20
21#[cfg(test)]
22use std::sync::RwLock;
23use std::{
24 sync::atomic::AtomicU64,
25 time::{Duration, SystemTime},
26};
27
28#[cfg(debug_assertions)]
29use std::{env::var as env_var, sync::LazyLock};
30
31pub const DEFAULT_CAT_DEV_SLOWDOWN: Duration = Duration::from_millis(25);
33pub const DEFAULT_CAT_DEV_CHUNK_SIZE: usize = 65536;
35const DEFAULT_SLOWLORIS_TIMEOUT: Duration = Duration::from_secs(10 * 60);
38static STREAM_ID: AtomicU64 = AtomicU64::new(1);
40#[cfg(feature = "servers")]
41static SERVER_ID: AtomicU64 = AtomicU64::new(1);
43static TCP_READ_BUFFER_SIZE: usize = 65536_usize;
45
46#[cfg(debug_assertions)]
48static SPRIG_TRACE_IO: LazyLock<bool> = LazyLock::new(|| {
49 if let Ok(variable) = env_var("SPRIG_FORCE_TRACE_ALL_IO") {
50 variable != "0" && !variable.is_empty()
51 } else {
52 false
53 }
54});
55
56thread_local! {
57 #[cfg(test)]
58 static CURRENT_TIME: LazyLock<RwLock<SystemTime>> = LazyLock::new(|| RwLock::new(SystemTime::now()));
59}
60
61#[cfg(not(test))]
62fn now() -> SystemTime {
63 SystemTime::now()
64}
65
66#[cfg(test)]
67fn now() -> SystemTime {
68 CURRENT_TIME.with(|time_lazy| time_lazy.read().expect("RwLock is poisioned?").clone())
69}
70
71#[cfg(test)]
72pub mod test_helpers {
73 #[cfg(feature = "servers")]
74 pub use crate::net::server::test_helpers::*;
75}