starnix_uapi/
file_lease.rs1use crate::errors::Errno;
6use crate::{error, uapi};
7
8#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
10pub enum FileLeaseType {
11 #[default]
13 Unlocked,
14
15 Read,
17
18 Write,
20}
21
22impl FileLeaseType {
23 pub fn from_bits(value: u32) -> Result<Self, Errno> {
24 match value {
25 uapi::F_UNLCK => Ok(Self::Unlocked),
26 uapi::F_RDLCK => Ok(Self::Read),
27 uapi::F_WRLCK => Ok(Self::Write),
28 _ => error!(EINVAL),
29 }
30 }
31
32 pub fn bits(&self) -> u32 {
33 match self {
34 Self::Unlocked => uapi::F_UNLCK,
35 Self::Read => uapi::F_RDLCK,
36 Self::Write => uapi::F_WRLCK,
37 }
38 }
39}