endpoint_sec/event/event_setmode.rs
1//! [`EventSetMode`]
2
3use endpoint_sec_sys::{es_event_setmode_t, mode_t};
4
5use crate::File;
6
7/// Modify file mode event.
8#[doc(alias = "es_event_setmode_t")]
9pub struct EventSetMode<'a> {
10 /// Raw event
11 pub(crate) raw: &'a es_event_setmode_t,
12}
13
14impl<'a> EventSetMode<'a> {
15 /// The desired new mode.
16 #[inline(always)]
17 pub fn mode(&self) -> mode_t {
18 self.raw.mode
19 }
20
21 /// The file for which mode information will be modified.
22 #[inline(always)]
23 pub fn target(&self) -> File<'a> {
24 // Safety: 'a tied to self, object obtained through ES
25 File::new(unsafe { self.raw.target() })
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 EventSetMode<'_> {}
31// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
32unsafe impl Sync for EventSetMode<'_> {}
33
34impl_debug_eq_hash_with_functions!(EventSetMode<'a>; mode, target);