endpoint_sec/event/event_setacl.rs
1//! [`EventSetAcl`]
2
3use endpoint_sec_sys::{acl_t, es_event_setacl_t, es_set_or_clear_t};
4
5use crate::File;
6
7/// Set a file ACL.
8#[doc(alias = "es_event_setacl_t")]
9pub struct EventSetAcl<'a> {
10 /// Raw event
11 pub(crate) raw: &'a es_event_setacl_t,
12}
13
14impl<'a> EventSetAcl<'a> {
15 /// File whose ACL is being set.
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 /// Whether the ACL on the [`target`][Self::target()] is being set or cleared
23 #[inline(always)]
24 pub fn set_or_clear(&self) -> es_set_or_clear_t {
25 self.raw.set_or_clear
26 }
27
28 /// The [`acl_t`] structure to be used by various acl(3) functions.
29 ///
30 /// Only available in the `ES_SET` case.
31 ///
32 /// Note: the provided acl cannot be used directly with the acl(3) functions, see documentation
33 /// on the original type, [`es_event_setacl_t`] for details.
34 #[inline(always)]
35 pub fn set(&self) -> Option<&'a acl_t> {
36 // Safety: the pointer is behind a lifetime tied to `self`
37 unsafe { self.raw.acl() }
38 }
39}
40
41// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
42unsafe impl Send for EventSetAcl<'_> {}
43// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
44unsafe impl Sync for EventSetAcl<'_> {}
45
46impl_debug_eq_hash_with_functions!(EventSetAcl<'a>; target, set_or_clear, set);