endpoint_sec/event/event_fcntl.rs
1//! [`EventFcntl`]
2
3use endpoint_sec_sys::es_event_fcntl_t;
4
5use crate::File;
6
7/// File control event.
8#[doc(alias = "es_event_fcntl_t")]
9pub struct EventFcntl<'a> {
10 /// Raw event
11 pub(crate) raw: &'a es_event_fcntl_t,
12}
13
14impl<'a> EventFcntl<'a> {
15 /// The target file on which the file control command will be performed.
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 cmd argument given to fcntl(2).
23 #[inline(always)]
24 pub fn cmd(&self) -> i32 {
25 self.raw.cmd
26 }
27}
28
29// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
30unsafe impl Send for EventFcntl<'_> {}
31// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
32unsafe impl Sync for EventFcntl<'_> {}
33
34impl_debug_eq_hash_with_functions!(EventFcntl<'a>; target, cmd);