endpoint_sec/event/event_setextattr.rs
1//! [`EventSetExtAttr`]
2
3use std::ffi::OsStr;
4
5use endpoint_sec_sys::es_event_setextattr_t;
6
7use crate::File;
8
9/// Set an extended attribute event.
10#[doc(alias = "es_event_setextattr_t")]
11pub struct EventSetExtAttr<'a> {
12 /// Raw event
13 pub(crate) raw: &'a es_event_setextattr_t,
14}
15
16impl<'a> EventSetExtAttr<'a> {
17 /// The extended attribute which will be set.
18 #[inline(always)]
19 pub fn extattr(&self) -> &'a OsStr {
20 // Safety: 'a tied to self, object obtained through ES
21 unsafe { self.raw.extattr.as_os_str() }
22 }
23
24 #[inline(always)]
25 /// The file for which the extended attribute will be set.
26 pub fn target(&self) -> File<'a> {
27 // Safety: 'a tied to self, object obtained through ES
28 File::new(unsafe { self.raw.target() })
29 }
30}
31
32// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
33unsafe impl Send for EventSetExtAttr<'_> {}
34// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
35unsafe impl Sync for EventSetExtAttr<'_> {}
36
37impl_debug_eq_hash_with_functions!(EventSetExtAttr<'a>; extattr, target);