fedimint_core/version.rs
1/// Get the cargo package version of `fedimint-core`
2pub fn cargo_pkg() -> &'static str {
3 env!("CARGO_PKG_VERSION")
4}
5
6/// Get the git hash version of `fedimint-core`
7///
8/// Note, in certain situations this not be accurate (eg. might be all `0`s).
9///
10/// The return value was injected via `fedimint-build` crate at the compile
11/// time.
12pub fn git_hash() -> &'static str {
13 option_env!("FEDIMINT_BUILD_CODE_VERSION").unwrap_or("0000000000000000000000000000000000000001")
14}
15
16/// Returns the version hash if it is meaningful (i.e. not all zeros, which
17/// `fedimint-build` substitutes when no git information is available).
18pub fn non_zero_version_hash(hash: &str) -> Option<&str> {
19 if hash.bytes().all(|b| b == b'0') {
20 None
21 } else {
22 Some(hash)
23 }
24}