1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Version and build information for Magellan
//!
//! Provides version string and build metadata (commit SHA, build date, rustc version).
/// Get the full version string including build metadata
///
/// Returns format: "magellan {version} ({commit} {date}) rustc {rustc_version} backends: {backends}"
pub fn version() -> String {
let version = env!("CARGO_PKG_VERSION");
let commit = build_commit();
let date = build_date();
let rustc_version = rustc_version();
let backends = compiled_backends();
format!(
"magellan {} ({} {}) rustc {} backends: {}",
version, commit, date, rustc_version, backends
)
}
/// Get the list of compiled backend features
///
/// Returns a comma-separated list like "sqlite" or "sqlite,geometric"
fn compiled_backends() -> String {
let mut backends = Vec::new();
#[cfg(feature = "sqlite-backend")]
backends.push("sqlite");
#[cfg(feature = "geometric-backend")]
backends.push("geometric");
if backends.is_empty() {
// Fallback - at least sqlite should be available
backends.push("sqlite");
}
backends.join(",")
}
/// Get the package version (e.g., "2.2.0")
///
/// Public API for programmatic version access - may be used by external tools.
#[expect(dead_code)]
pub fn package_version() -> &'static str {
env!("CARGO_PKG_VERSION")
}
/// Get the package version (e.g., "2.2.0")
/// Get the build commit SHA
///
/// Returns "unknown" if not built with commit info
pub fn build_commit() -> &'static str {
option_env!("MAGELLAN_COMMIT_SHA").unwrap_or("unknown")
}
/// Get the build date
///
/// Returns "unknown" if not built with date info
pub fn build_date() -> &'static str {
option_env!("MAGELLAN_BUILD_DATE").unwrap_or("unknown")
}
/// Get the Rust compiler version used for the build
///
/// Returns "unknown" if not built with rustc version info
pub fn rustc_version() -> &'static str {
option_env!("MAGELLAN_RUSTC_VERSION").unwrap_or("unknown")
}