endpoint_sec/
acl.rs

1//! [`Acl`] is wrapper around ACLs received from Endpoint Security.
2//!
3//! **Important**: ACLs generated by Endpoint Security are **not** directly compatible
4//! with `sys/acl.h`, be sure to check up-to-date documentation for your macOS target.
5
6use endpoint_sec_sys::{_acl, acl_t};
7
8/// ACL from Endpoint Security.
9// **DO NOT USE DIRECTLY WITH `sys/acl.h`**
10// TODO: correctly implement Debug/Eq/Hash for ACLs
11#[doc(alias = "acl_t")]
12#[doc(alias = "_acl")]
13pub struct Acl<'a>(#[allow(unused)] &'a _acl);
14
15impl Acl<'_> {
16    /// Builds an ACL wrapper from the raw one.
17    ///
18    /// `None` if the given ACL is NULL inside.
19    pub(crate) fn from_raw(r: acl_t) -> Option<Self> {
20        // Safety: let's hope Apple gave us an aligned and initialized pointer
21        unsafe { r.as_ref() }.map(Self)
22    }
23
24    // NOTE: in the future, if we need to interact with `sys/acl.h`, remember to read the docs
25    // in ESMessage.h, there are details to the way it should be done.
26}
27
28static_assertions::assert_impl_all!(Acl<'_>: Send);
29
30impl_debug_eq_hash_with_functions!(Acl<'a>;);