async_fuser/
open_flags.rs1use std::fmt;
2use std::fmt::Formatter;
3use std::fmt::LowerHex;
4use std::fmt::UpperHex;
5
6#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
8#[repr(i32)]
9#[allow(non_camel_case_types)]
10pub enum OpenAccMode {
11 O_RDONLY = libc::O_RDONLY,
13 O_WRONLY = libc::O_WRONLY,
15 O_RDWR = libc::O_RDWR,
17}
18
19#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
21pub struct OpenFlags(pub i32);
22
23impl LowerHex for OpenFlags {
24 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
25 LowerHex::fmt(&self.0, f)
26 }
27}
28
29impl UpperHex for OpenFlags {
30 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
31 UpperHex::fmt(&self.0, f)
32 }
33}
34
35impl OpenFlags {
36 pub fn acc_mode(self) -> OpenAccMode {
38 match self.0 & libc::O_ACCMODE {
39 libc::O_RDONLY => OpenAccMode::O_RDONLY,
40 libc::O_WRONLY => OpenAccMode::O_WRONLY,
41 libc::O_RDWR => OpenAccMode::O_RDWR,
42 _ => {
43 OpenAccMode::O_RDONLY
46 }
47 }
48 }
49}