1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! [`EventOpen`]

use endpoint_sec_sys::es_event_open_t;

use crate::File;

/// File system object open event.
#[doc(alias = "es_event_open_t")]
pub struct EventOpen<'a> {
    /// Raw event
    pub(super) raw: &'a es_event_open_t,
}

impl<'a> EventOpen<'a> {
    /// The desired **kernel** flags to be used when opening the file.
    #[inline(always)]
    pub fn fflag(&self) -> i32 {
        self.raw.fflag
    }

    /// The file that will be opened.
    #[inline(always)]
    pub fn file(&self) -> File<'_> {
        // Safety: 'a tied to self, object obtained through ES
        File::new(unsafe { self.raw.file() })
    }
}

// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
unsafe impl Send for EventOpen<'_> {}

impl_debug_eq_hash_with_functions!(EventOpen<'a>; fflag, file);