endpoint_sec/event/
event_profile_add.rs1use std::ffi::OsStr;
4
5use endpoint_sec_sys::{es_event_profile_add_t, es_profile_source_t, es_profile_t};
6
7use crate::{AuditToken, Process};
8
9#[doc(alias = "es_event_profile_add_t")]
11pub struct EventProfileAdd<'a> {
12 pub(crate) raw: &'a es_event_profile_add_t,
14 pub(crate) version: u32,
16}
17
18impl<'a> EventProfileAdd<'a> {
19 #[inline(always)]
21 pub fn instigator(&self) -> Option<Process<'a>> {
22 let process = unsafe { self.raw.instigator()? };
24 Some(Process::new(process, self.version))
25 }
26
27 pub fn instigator_token(&self) -> AuditToken {
29 #[cfg(feature = "macos_15_0_0")]
30 if self.version >= 8 {
31 return AuditToken(self.raw.instigator_token);
32 }
33
34 self.instigator().unwrap().audit_token()
37 }
38
39 #[inline(always)]
41 pub fn is_update(&self) -> bool {
42 self.raw.is_update
43 }
44
45 #[inline(always)]
47 pub fn profile(&self) -> Profile<'a> {
48 Profile {
49 raw: unsafe { self.raw.profile.as_ref() },
51 }
52 }
53}
54
55unsafe impl Send for EventProfileAdd<'_> {}
57unsafe impl Sync for EventProfileAdd<'_> {}
59
60impl_debug_eq_hash_with_functions!(EventProfileAdd<'a> with version; instigator, instigator_token, is_update, profile);
61
62#[doc(alias = "es_profile_t")]
64pub struct Profile<'a> {
65 pub(crate) raw: &'a es_profile_t,
67}
68
69impl<'a> Profile<'a> {
70 #[inline(always)]
72 pub fn identifier(&self) -> &'a OsStr {
73 unsafe { self.raw.identifier.as_os_str() }
75 }
76
77 #[inline(always)]
79 pub fn uuid(&self) -> &'a OsStr {
80 unsafe { self.raw.uuid.as_os_str() }
82 }
83
84 #[inline(always)]
86 pub fn install_source(&self) -> es_profile_source_t {
87 self.raw.install_source
88 }
89
90 #[inline(always)]
92 pub fn organization(&self) -> &'a OsStr {
93 unsafe { self.raw.organization.as_os_str() }
95 }
96
97 #[inline(always)]
99 pub fn display_name(&self) -> &'a OsStr {
100 unsafe { self.raw.display_name.as_os_str() }
102 }
103
104 #[inline(always)]
106 pub fn scope(&self) -> &'a OsStr {
107 unsafe { self.raw.scope.as_os_str() }
109 }
110}
111
112unsafe impl Send for Profile<'_> {}
114
115impl_debug_eq_hash_with_functions!(Profile<'a>; identifier, uuid, install_source, organization, display_name, scope);