endpoint_sec/event/
event_iokit_open.rs

1//! [`EventIoKitOpen`]
2
3use std::ffi::OsStr;
4
5use endpoint_sec_sys::es_event_iokit_open_t;
6
7/// Open a connection to an I/O Kit IOService event.
8#[doc(alias = "es_event_iokit_open_t")]
9pub struct EventIoKitOpen<'a> {
10    /// Raw event
11    pub(crate) raw: &'a es_event_iokit_open_t,
12}
13
14impl<'a> EventIoKitOpen<'a> {
15    /// A constant specifying the type of connection to be created, interpreted only by the IOService's family.
16    ///
17    /// **Note**: This corresponds to the type argument to `IOServiceOpen()`.
18    #[inline(always)]
19    pub fn user_client_type(&self) -> u32 {
20        self.raw.user_client_type
21    }
22
23    /// The name of the new object linked to the source file.
24    #[inline(always)]
25    pub fn user_client_class(&self) -> &'a OsStr {
26        // Safety: 'a tied to self, object obtained through ES
27        unsafe { self.raw.user_client_class.as_os_str() }
28    }
29}
30
31// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
32unsafe impl Send for EventIoKitOpen<'_> {}
33// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
34unsafe impl Sync for EventIoKitOpen<'_> {}
35
36impl_debug_eq_hash_with_functions!(EventIoKitOpen<'a>; user_client_type, user_client_class);