bnr_xfs/denominations/denomination_info/
security_level.rs

1use std::fmt;
2
3use crate::impl_xfs_i4;
4
5/// Represents the security level for acceptance of a denomination specified by a [DenominationInfo].
6#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7pub struct SecurityLevel(u32);
8
9impl SecurityLevel {
10    /// Creates a new [SecurityLevel].
11    pub const fn new() -> Self {
12        Self(0)
13    }
14
15    /// Creates a new [SecurityLevel] from the provided parameter.
16    pub const fn create(c: u32) -> Self {
17        Self(c)
18    }
19
20    /// Gets the inner representation of the [SecurityLevel].
21    pub const fn inner(&self) -> u32 {
22        self.0
23    }
24
25    /// Sets the inner representation of the [SecurityLevel].
26    pub fn set_inner(&mut self, v: u32) {
27        self.0 = v;
28    }
29
30    /// Converts into the inner representation of the [SecurityLevel].
31    pub fn into_inner(self) -> u32 {
32        self.0
33    }
34}
35
36impl Default for SecurityLevel {
37    fn default() -> Self {
38        Self::new()
39    }
40}
41
42impl fmt::Display for SecurityLevel {
43    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44        write!(f, "{}", self.inner())
45    }
46}
47
48impl_xfs_i4!(SecurityLevel, "securityLevel");