1use cfg_if::cfg_if;
2
3cfg_if! {
4 if #[cfg(feature = "full")] {
5 pub mod cache_header;
6 pub mod email;
7 pub mod rate_limit;
8 pub mod request;
9 pub mod response;
10 pub mod settings;
11 pub mod utils;
12 }
13}
14
15pub mod error;
16pub use error::LemmyErrorType;
17use std::time::Duration;
18
19pub type ConnectionId = usize;
20
21#[cfg(not(debug_assertions))]
24pub const VERSION: &str = git_version::git_version!(
25 args = ["--tags", "--dirty=-modified"],
26 fallback = env!("CARGO_PKG_VERSION")
27);
28#[cfg(debug_assertions)]
29pub const VERSION: &str = env!("CARGO_PKG_VERSION");
30
31pub const REQWEST_TIMEOUT: Duration = Duration::from_secs(10);
32
33#[cfg(debug_assertions)]
34pub const CACHE_DURATION_FEDERATION: Duration = Duration::from_millis(500);
35#[cfg(not(debug_assertions))]
36pub const CACHE_DURATION_FEDERATION: Duration = Duration::from_secs(60);
37
38pub const CACHE_DURATION_API: Duration = Duration::from_secs(1);
39
40pub const MAX_COMMENT_DEPTH_LIMIT: usize = 50;
41
42#[macro_export]
43macro_rules! location_info {
44 () => {
45 format!(
46 "None value at {}:{}, column {}",
47 file!(),
48 line!(),
49 column!()
50 )
51 };
52}
53
54#[cfg(feature = "full")]
55pub fn spawn_try_task(
59 task: impl futures::Future<Output = Result<(), error::LemmyError>> + Send + 'static,
60) {
61 use tracing::Instrument;
62 tokio::spawn(
63 async {
64 if let Err(e) = task.await {
65 tracing::warn!("error in spawn: {e}");
66 }
67 }
68 .in_current_span(), );
71}