#![allow(non_camel_case_types)]
macro_rules! get_env {
($k:tt) => {
match option_env!($k) {
Some(v) => v,
None => "",
}
}
}
pub mod cfg;
pub use cfg::cfg_info;
pub mod vergen;
pub mod cargo;
pub mod env;
pub mod source;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct rsinfo {
cfg: cfg::cfg_info,
vergen: vergen::vergen_info,
cargo: cargo::cargo_info,
env: env::env_info,
source: [&'static str; source::SOURCE_CODE_LIST_LEN],
}
#[cfg(feature = "json")]
impl rsinfo {
pub fn to_json(&self) -> serde_json::Value {
serde_json::json!({
"rsinfo": option_env!("CARGO_PKG_VERSION").unwrap_or("(N/A)"),
"data": {
"cfg": self.cfg.to_json(),
"vergen": self.vergen.to_json(),
"cargo": self.cargo.to_json(),
"env": self.env.to_json(),
},
})
}
}
impl core::fmt::Debug for rsinfo {
fn fmt(&self, f: &mut core::fmt::Formatter)
-> Result<(), core::fmt::Error>
{
f.debug_struct("rsinfo")
.field("cfg", &self.cfg)
.field("vergen", &self.vergen)
.field("cargo", &self.cargo)
.field("env", &self.env)
.finish()
}
}
pub const ALL_INFO: rsinfo = all_info();
pub const fn all_info() -> rsinfo {
rsinfo {
cfg: cfg::ALL_INFO,
vergen: vergen::ALL_INFO,
cargo: cargo::ALL_INFO,
env: env::ALL_INFO,
source: source::SOURCE_CODE_LIST,
}
}