1#![deny(missing_docs)]
2#![deny(unsafe_code)]
3#![doc = include_str!("README.tpl")]
4include!(concat!(env!("OUT_DIR"), "/readme.rs"));
9
10pub mod deps {
12 pub use base64;
13 pub use serde;
14 pub use serde_json;
15}
16
17mod error;
18pub use error::*;
19
20mod evt;
21pub use evt::*;
22
23#[cfg(feature = "file_check")]
24pub mod file_check;
25
26pub type BoxFut<'lt, T> =
28 std::pin::Pin<Box<dyn std::future::Future<Output = T> + 'lt + Send>>;
29
30#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
34#[serde(crate = "deps::serde", rename_all = "camelCase")]
35pub struct Tx5InitConfig {
36 pub tracing_enabled: bool,
39
40 pub ephemeral_udp_port_min: u16,
42
43 pub ephemeral_udp_port_max: u16,
45}
46
47impl Default for Tx5InitConfig {
48 fn default() -> Self {
49 Self {
50 tracing_enabled: false,
51 ephemeral_udp_port_min: 1,
52 ephemeral_udp_port_max: 65535,
53 }
54 }
55}
56
57impl Tx5InitConfig {
58 pub fn set_as_global_default(&self) -> Result<()> {
61 TX5_INIT_CONFIG
62 .set(*self)
63 .map_err(|_| Error::id("Tx5InitAlreadySet"))
64 }
65
66 pub fn get() -> Self {
70 *TX5_INIT_CONFIG.get_or_init(Tx5InitConfig::default)
71 }
72}
73
74static TX5_INIT_CONFIG: once_cell::sync::OnceCell<Tx5InitConfig> =
75 once_cell::sync::OnceCell::new();