| 1 |
use std::borrow::Cow; |
| 2 |
|
| 3 |
use minidump::system_info::{Cpu, Os}; |
| 4 |
|
| 5 |
/// Information about the system that produced a `Minidump`. |
| 6 |
#[derive(Debug, Clone)] |
| 7 |
pub struct SystemInfo { |
| 8 |
/// The operating system that produced the minidump |
| 9 |
pub os: Os, |
| 10 |
/// A string identifying the version of the operating system. |
| 11 |
/// |
| 12 |
/// This may look like "5.1.2600" or "10.4.8", if present |
| 13 |
pub os_version: Option<String>, |
| 14 |
/// A string identifying the exact build of the operating system. |
| 15 |
/// |
| 16 |
/// This may look like "Service Pack 2" or "8L2127", if present. On Windows, |
| 17 |
/// this is the CSD version, on Linux, extended build information and macOS, |
| 18 |
/// the product build version. |
| 19 |
pub os_build: Option<String>, |
| 20 |
/// The CPU on which the dump was produced |
| 21 |
pub cpu: Cpu, |
| 22 |
/// A string further identifying the specific CPU |
| 23 |
/// |
| 24 |
/// For example, "GenuineIntel level 6 model 13 stepping 8", if present. |
| 25 |
pub cpu_info: Option<String>, |
| 26 |
/// The microcode version of the cpu |
| 27 |
pub cpu_microcode_version: Option<u64>, |
| 28 |
/// The number of processors in the system |
| 29 |
/// |
| 30 |
/// Will be greater than one for multi-core systems. |
| 31 |
pub cpu_count: usize, |
| 32 |
} |
| 33 |
|
| 34 |
impl SystemInfo { |
| 35 |
/// Returns the full available operating system version. |
| 36 |
/// |
| 37 |
/// Returns the version and the build, if available, otherwise just the version. |
| 38 |
pub fn format_os_version(&self) -> Option<Cow<'_, str>> { |
| 39 |
match (&self.os_version, &self.os_build) { |
| 40 |
(Some(v), Some(b)) => Some(format!("{v} {b}").into()), |
| 41 |
(Some(v), None) => Some(Cow::Borrowed(v)), |
| 42 |
(None, Some(b)) => Some(Cow::Borrowed(b)), |
| 43 |
(None, None) => None, |
| 44 |
} |
| 45 |
} |
| 46 |
} |