bnr_xfs/cash_unit/
lock.rs1use std::fmt;
2
3use crate::impl_xfs_bool;
4
5#[repr(C)]
7#[derive(Clone, Copy, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
8pub struct Lock(bool);
9
10impl Lock {
11 pub const fn new() -> Self {
13 Self(false)
14 }
15
16 pub const fn create(v: bool) -> Self {
18 Self(v)
19 }
20
21 pub const fn inner(&self) -> bool {
23 self.0
24 }
25
26 pub fn set_inner(&mut self, v: bool) {
28 self.0 = v;
29 }
30
31 pub fn into_inner(self) -> bool {
33 self.0
34 }
35}
36
37impl fmt::Display for Lock {
38 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
39 write!(f, "{}", self.inner())
40 }
41}
42
43impl_xfs_bool!(Lock, "lock");