endpoint_sec/event/event_xpc_connect.rs
1//! [`EventXpcConnect`]
2
3use std::ffi::OsStr;
4
5use endpoint_sec_sys::{es_event_xpc_connect_t, es_xpc_domain_type_t};
6
7/// Notification for an XPC connection being established to a named service.
8#[doc(alias = "es_event_xpc_connect_t")]
9pub struct EventXpcConnect<'a> {
10 /// The raw reference.
11 pub(crate) raw: &'a es_event_xpc_connect_t,
12}
13
14impl<'a> EventXpcConnect<'a> {
15 /// Service name of the named service.
16 #[inline(always)]
17 pub fn service_name(&self) -> &'a OsStr {
18 // Safety: 'a tied to self, object obtained through ES
19 unsafe { self.raw.service_name.as_os_str() }
20 }
21
22 /// The type of XPC domain in which the service resides in.
23 #[inline(always)]
24 pub fn service_domain_type(&self) -> es_xpc_domain_type_t {
25 self.raw.service_domain_type
26 }
27}
28
29// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
30unsafe impl Send for EventXpcConnect<'_> {}
31// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
32unsafe impl Sync for EventXpcConnect<'_> {}
33
34impl_debug_eq_hash_with_functions!(EventXpcConnect<'a>; service_name, service_domain_type);