Skip to main content

endpoint_sec/event/
event_unlink.rs

1//! [`EventUnlink`]
2
3use endpoint_sec_sys::es_event_unlink_t;
4
5use crate::File;
6
7/// Unlink a file system object event.
8#[doc(alias = "es_event_unlink_t")]
9pub struct EventUnlink<'a> {
10    /// Raw event
11    pub(crate) raw: &'a es_event_unlink_t,
12}
13
14impl<'a> EventUnlink<'a> {
15    /// The object that will be removed.
16    #[inline(always)]
17    pub fn target(&self) -> File<'a> {
18        // Safety: 'a tied to self, object obtained through ES
19        File::new(unsafe { self.raw.target() })
20    }
21
22    /// The parent directory of the `target` file system object.
23    #[inline(always)]
24    pub fn parent_dir(&self) -> File<'a> {
25        // Safety: 'a tied to self, object obtained through ES
26        File::new(unsafe { self.raw.parent_dir() })
27    }
28}
29
30// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
31unsafe impl Send for EventUnlink<'_> {}
32// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
33unsafe impl Sync for EventUnlink<'_> {}
34
35impl_debug_eq_hash_with_functions!(EventUnlink<'a>; target, parent_dir);