2024-07-24 01:06:58 +00:00
|
|
|
//! one true function for returning the conduwuit version with the necessary
|
|
|
|
//! CONDUWUIT_VERSION_EXTRA env variables used if specified
|
|
|
|
//!
|
|
|
|
//! Set the environment variable `CONDUWUIT_VERSION_EXTRA` to any UTF-8 string
|
|
|
|
//! to include it in parenthesis after the SemVer version. A common value are
|
|
|
|
//! git commit hashes.
|
|
|
|
|
2024-06-24 22:06:20 +00:00
|
|
|
use std::sync::OnceLock;
|
|
|
|
|
2025-04-16 13:52:28 +01:00
|
|
|
static BRANDING: &str = "continuwuity";
|
2024-06-24 22:06:20 +00:00
|
|
|
static SEMANTIC: &str = env!("CARGO_PKG_VERSION");
|
|
|
|
|
|
|
|
static VERSION: OnceLock<String> = OnceLock::new();
|
|
|
|
static USER_AGENT: OnceLock<String> = OnceLock::new();
|
|
|
|
|
|
|
|
#[inline]
|
2024-05-27 20:05:33 +00:00
|
|
|
#[must_use]
|
2024-06-24 22:06:20 +00:00
|
|
|
pub fn name() -> &'static str { BRANDING }
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub fn version() -> &'static str { VERSION.get_or_init(init_version) }
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub fn user_agent() -> &'static str { USER_AGENT.get_or_init(init_user_agent) }
|
|
|
|
|
|
|
|
fn init_user_agent() -> String { format!("{}/{}", name(), version()) }
|
|
|
|
|
|
|
|
fn init_version() -> String {
|
2025-05-21 12:35:25 +01:00
|
|
|
conduwuit_build_metadata::version_tag()
|
2025-05-01 00:38:35 +01:00
|
|
|
.map_or(SEMANTIC.to_owned(), |extra| format!("{SEMANTIC} ({extra})"))
|
2024-05-27 20:05:33 +00:00
|
|
|
}
|