omf/
version.rs

1/// Library name.
2pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
3
4/// Library version.
5pub const CRATE_VERSION: &str = env!("CARGO_PKG_VERSION");
6
7/// File format name.
8pub const FORMAT_NAME: &str = "Open Mining Format";
9
10/// File format extension.
11pub const FORMAT_EXTENSION: &str = "omf";
12
13/// File format major version number.
14pub const FORMAT_VERSION_MAJOR: u32 = 2;
15
16/// File format minor version number.
17pub const FORMAT_VERSION_MINOR: u32 = 0;
18
19/// File format pre-release version suffix.
20///
21/// This will always be `None` in release versions of the crate. Pre-release formats
22/// may contain experimental changes so can't be opened in by release versions.
23pub const FORMAT_VERSION_PRERELEASE: Option<&str> = Some("beta.1");
24
25/// Returns a string containing the file format version that this crate produces.
26pub fn format_version() -> String {
27    let mut v = format!("{FORMAT_VERSION_MAJOR}.{FORMAT_VERSION_MINOR}");
28    if let Some(pre) = FORMAT_VERSION_PRERELEASE {
29        v = format!("{v}-{pre}");
30    }
31    v
32}
33
34/// Returns a string containing the full name and version of the file format that this
35/// crate produces.
36pub fn format_full_name() -> String {
37    format!("{} {}", FORMAT_NAME, format_version())
38}
39
40/// Returns the crate name and version.
41pub fn crate_full_name() -> String {
42    format!("{CRATE_NAME} {CRATE_VERSION}")
43}