libdd_crashtracker/crash_info/
os_info.rs1use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use super::unknown_value::UnknownValue;
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
9pub struct OsInfo {
10 pub architecture: String,
11 pub bitness: String,
12 pub os_type: String,
13 pub version: String,
14}
15
16impl UnknownValue for OsInfo {
17 fn unknown_value() -> Self {
18 os_info::Info::unknown().into()
19 }
20}
21
22impl From<os_info::Info> for OsInfo {
23 fn from(value: os_info::Info) -> Self {
24 let architecture = value.architecture().unwrap_or("unknown").to_string();
25 let bitness = value.bitness().to_string();
26 let os_type = value.os_type().to_string();
27 let version = value.version().to_string();
28 Self {
29 architecture,
30 bitness,
31 os_type,
32 version,
33 }
34 }
35}