intel_crashlog/collateral/
pvss.rs1#[cfg(not(feature = "std"))]
5use alloc::{fmt, string::String};
6#[cfg(feature = "std")]
7use std::{fmt, path::PathBuf};
8
9#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
13pub struct PVSS {
14 pub product: String,
16 pub variant: String,
18 pub stepping: String,
20 pub security: String,
22}
23
24impl Default for PVSS {
25 fn default() -> Self {
26 PVSS {
27 product: "all".into(),
28 variant: "all".into(),
29 stepping: "all".into(),
30 security: "all".into(),
31 }
32 }
33}
34
35#[cfg(feature = "std")]
36impl From<&PVSS> for PathBuf {
37 fn from(pvss: &PVSS) -> Self {
38 [&pvss.product, &pvss.variant, &pvss.stepping, &pvss.security]
39 .iter()
40 .filter(|p| **p != "." && **p != "..")
41 .collect()
42 }
43}
44
45impl fmt::Display for PVSS {
46 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
47 write!(
48 f,
49 "{}/{}/{}/{}",
50 self.product, self.variant, self.stepping, self.security
51 )?;
52 Ok(())
53 }
54}