intel_crashlog/
metadata.rs1mod time;
7
8#[cfg(not(feature = "std"))]
9use alloc::vec::Vec;
10#[cfg(not(feature = "std"))]
11use alloc::{fmt, string::String};
12#[cfg(feature = "std")]
13use std::fmt;
14
15use crate::cper::CperSectionBody;
16use crate::source::CrashLogSource;
17
18pub use time::Time;
19
20#[derive(Default, Clone)]
22pub struct Metadata {
23 pub computer: Option<String>,
25 pub source: Option<CrashLogSource>,
27 pub time: Option<Time>,
29 pub extra_cper_sections: Vec<CperSectionBody>,
32}
33
34impl fmt::Display for Metadata {
35 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
36 let mut sep = "";
37
38 if let Some(computer) = &self.computer {
39 write!(f, "{computer}")?;
40 sep = "-";
41 }
42
43 if let Some(source) = &self.source {
44 write!(f, "{sep}{source}")?;
45 sep = "-";
46 }
47
48 if let Some(time) = &self.time {
49 write!(f, "{sep}{time}")?;
50 sep = "-";
51 }
52
53 if sep.is_empty() {
54 write!(f, "unnamed")?;
55 }
56
57 Ok(())
58 }
59}