endpoint_sec/event/event_getextattr.rs
1//! [`EventGetExtAttr`]
2
3use std::ffi::OsStr;
4
5use endpoint_sec_sys::es_event_getextattr_t;
6
7use crate::File;
8
9/// Retrieve an extended attribute event.
10#[doc(alias = "es_event_getextattr_t")]
11pub struct EventGetExtAttr<'a> {
12 /// Raw event
13 pub(crate) raw: &'a es_event_getextattr_t,
14}
15
16impl<'a> EventGetExtAttr<'a> {
17 /// The extended attribute which will be retrieved.
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 /// The file for which the extended attribute will be retrieved.
25 #[inline(always)]
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 EventGetExtAttr<'_> {}
34// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
35unsafe impl Sync for EventGetExtAttr<'_> {}
36
37impl_debug_eq_hash_with_functions!(EventGetExtAttr<'a>; extattr, target);