bnr_xfs/capabilities/
reporting_mode.rs1use std::fmt;
2
3use crate::impl_xfs_enum;
4
5const REPORTING_NORMAL: u32 = 0;
6const REPORTING_FULL: u32 = 1;
7
8#[repr(u32)]
10#[derive(Clone, Copy, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
11pub enum ReportingMode {
12 #[default]
14 Normal = REPORTING_NORMAL,
15 Full = REPORTING_FULL,
17}
18
19impl ReportingMode {
20 pub const fn new() -> Self {
22 Self::Normal
23 }
24
25 pub const fn create(val: u32) -> Self {
27 match val {
28 REPORTING_NORMAL => Self::Normal,
29 REPORTING_FULL => Self::Full,
30 _ => Self::Normal,
31 }
32 }
33}
34
35impl From<&ReportingMode> for &'static str {
36 fn from(val: &ReportingMode) -> Self {
37 match val {
38 ReportingMode::Normal => "normal",
39 ReportingMode::Full => "full",
40 }
41 }
42}
43
44impl From<ReportingMode> for &'static str {
45 fn from(val: ReportingMode) -> Self {
46 (&val).into()
47 }
48}
49
50impl fmt::Display for ReportingMode {
51 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
52 write!(f, r#""{}""#, <&str>::from(self))
53 }
54}
55
56impl_xfs_enum!(ReportingMode, "reportingMode");