pub struct Sysinfo { /* private fields */ }Available on crate feature
si only.Expand description
The VERGEN_SYSINFO_* configuration features
| Variable | Sample |
|---|---|
VERGEN_SYSINFO_NAME | Manjaro Linux |
VERGEN_SYSINFO_OS_VERSION | Linux Manjaro Linux |
VERGEN_SYSINFO_USER | Yoda |
VERGEN_SYSINFO_TOTAL_MEMORY | 33 GB |
VERGEN_SYSINFO_CPU_VENDOR | Authentic AMD |
VERGEN_SYSINFO_CPU_CORE_COUNT | 8 |
VERGEN_SYSINFO_CPU_NAME | cpu0,cpu1,cpu2,cpu3,cpu4,cpu5,cpu6,cpu7 |
VERGEN_SYSINFO_CPU_BRAND | AMD Ryzen Threadripper 1900X 8-Core Processor |
VERGEN_SYSINFO_CPU_FREQUENCY | 3792 |
§Example
Emit all sysinfo instructions
let si = Sysinfo::all_sysinfo();
Emitter::default().add_instructions(&si)?.emit()?;Emit some of the sysinfo instructions
let si = Sysinfo::builder().os_version(true).cpu_core_count(true).build();
Emitter::default()
.add_instructions(&si)?
.emit()?;Override output with your own value
temp_env::with_var("VERGEN_SYSINFO_NAME", Some("this is the name I want output"), || {
let result = || -> Result<()> {
let si = Sysinfo::all_sysinfo();
Emitter::default().add_instructions(&si)?.emit()?;
Ok(())
}();
assert!(result.is_ok());
});§Example
This feature also recognizes the idempotent flag.
let si = Sysinfo::all_sysinfo();
Emitter::default().idempotent().add_instructions(&si)?.emit()?;§Example
Use refresh_kind to minimize the amount of data that sysinfo refreshes.
let refresh_kind = RefreshKind::nothing();
let cpu_refresh_kind = CpuRefreshKind::everything()
.without_cpu_usage()
.without_frequency();
let si = Sysinfo::builder()
.cpu_brand(true)
.refresh_kind(refresh_kind.with_cpu(cpu_refresh_kind))
.build();
let config = Emitter::default()
.add_instructions(&si)?
.emit()?;The above will always generate the following output
cargo:rustc-env=VERGEN_SYSINFO_NAME=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_OS_VERSION=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_USER=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_TOTAL_MEMORY=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_VENDOR=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_CORE_COUNT=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_NAME=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_BRAND=VERGEN_IDEMPOTENT_OUTPUT
cargo:rustc-env=VERGEN_SYSINFO_CPU_FREQUENCY=VERGEN_IDEMPOTENT_OUTPUT
cargo:warning=VERGEN_SYSINFO_NAME set to default
cargo:warning=VERGEN_SYSINFO_OS_VERSION set to default
cargo:warning=VERGEN_SYSINFO_USER set to default
cargo:warning=VERGEN_SYSINFO_TOTAL_MEMORY set to default
cargo:warning=VERGEN_SYSINFO_CPU_VENDOR set to default
cargo:warning=VERGEN_SYSINFO_CPU_CORE_COUNT set to default
cargo:warning=VERGEN_SYSINFO_CPU_NAME set to default
cargo:warning=VERGEN_SYSINFO_CPU_BRAND set to default
cargo:warning=VERGEN_SYSINFO_CPU_FREQUENCY set to default
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=VERGEN_IDEMPOTENT
cargo:rerun-if-env-changed=SOURCE_DATE_EPOCHImplementations§
Trait Implementations§
Source§impl Add for Sysinfo
impl Add for Sysinfo
Source§fn add_map_entries(
&self,
idempotent: bool,
cargo_rustc_env: &mut BTreeMap<VergenKey, String>,
_cargo_rerun_if_changed: &mut Vec<String>,
cargo_warning: &mut Vec<String>,
) -> Result<(), Error>
fn add_map_entries( &self, idempotent: bool, cargo_rustc_env: &mut BTreeMap<VergenKey, String>, _cargo_rerun_if_changed: &mut Vec<String>, cargo_warning: &mut Vec<String>, ) -> Result<(), Error>
Try to add instructions entries to the various given arguments. Read more
Source§fn add_default_entries(
&self,
_config: &DefaultConfig,
_cargo_rustc_env_map: &mut BTreeMap<VergenKey, String>,
_cargo_rerun_if_changed: &mut Vec<String>,
_cargo_warning: &mut Vec<String>,
) -> Result<(), Error>
fn add_default_entries( &self, _config: &DefaultConfig, _cargo_rustc_env_map: &mut BTreeMap<VergenKey, String>, _cargo_rerun_if_changed: &mut Vec<String>, _cargo_warning: &mut Vec<String>, ) -> Result<(), Error>
Based on the given configuration, emit either default idempotent output or generate a failue. Read more
impl Copy for Sysinfo
impl StructuralPartialEq for Sysinfo
Auto Trait Implementations§
impl Freeze for Sysinfo
impl RefUnwindSafe for Sysinfo
impl Send for Sysinfo
impl Sync for Sysinfo
impl Unpin for Sysinfo
impl UnwindSafe for Sysinfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more