1//! General constants used throughout `cuprated`.
2use std::time::Duration;
34use const_format::formatcp;
56/// `cuprated`'s semantic version (`MAJOR.MINOR.PATCH`) as string.
7pub const VERSION: &str = clap::crate_version!();
89/// Major version number of `cuprated`.
10pub const MAJOR_VERSION: &str = env!("CARGO_PKG_VERSION_MAJOR");
1112/// Major version number of `cuprated`.
13pub const MINOR_VERSION: &str = env!("CARGO_PKG_VERSION_MINOR");
1415/// Patch version number of `cuprated`.
16pub const PATCH_VERSION: &str = env!("CARGO_PKG_VERSION_PATCH");
1718/// [`VERSION`] + the build type.
19///
20/// If a debug build, the suffix is `-debug`, else it is `-release`.
21pub const VERSION_BUILD: &str = formatcp!("{VERSION}-{}", cuprate_constants::build::BUILD);
2223/// The panic message used when cuprated encounters a critical service error.
24pub const PANIC_CRITICAL_SERVICE_ERROR: &str =
25"A service critical to Cuprate's function returned an unexpected error.";
2627pub const DEFAULT_CONFIG_WARNING: &str = formatcp!(
28"WARNING: no config file found, using default config.\
29 \nThe default config may not be optimal for your setup, see the user book here: https://user.cuprate.org/.\
30 \nPausing startup for {} seconds. \
31 \nUse the `--skip-config-warning` arg to skip this delay if you really want to use the default.",
32 DEFAULT_CONFIG_STARTUP_DELAY.as_secs()
33);
3435pub const DEFAULT_CONFIG_STARTUP_DELAY: Duration = Duration::from_secs(15);
3637#[cfg(test)]
38mod test {
39use super::*;
40use crate::config::Config;
4142#[test]
43fn version() {
44let semantic_version = format!("{MAJOR_VERSION}.{MINOR_VERSION}.{PATCH_VERSION}");
45assert_eq!(VERSION, VERSION);
46assert_eq!(VERSION, "0.0.2");
47 }
4849#[test]
50fn version_build() {
51if cfg!(debug_assertions) {
52assert_eq!(VERSION_BUILD, "0.0.2-debug");
53 } else {
54assert_eq!(VERSION_BUILD, "0.0.2-release");
55 }
56 }
57}