endpoint_sec/event/event_btm_launch_item_remove.rs
1//! [`EventBtmLaunchItemRemove`]
2
3use endpoint_sec_sys::es_event_btm_launch_item_remove_t;
4
5use crate::{BtmLaunchItem, Process};
6
7/// A launch item being removed from background task management.
8#[doc(alias = "es_event_btm_launch_item_add_t")]
9pub struct EventBtmLaunchItemRemove<'a> {
10 /// Raw event
11 pub(crate) raw: &'a es_event_btm_launch_item_remove_t,
12 /// Message version
13 pub(crate) version: u32,
14}
15
16impl<'a> EventBtmLaunchItemRemove<'a> {
17 /// Optional. Process that instigated the BTM operation (XPC caller that asked for the item to
18 /// be removed).
19 #[inline(always)]
20 pub fn instigator(&self) -> Option<Process<'a>> {
21 // Safety: 'a tied to self, object obtained through ES
22 let process = unsafe { self.raw.instigator()? };
23 Some(Process::new(process, self.version))
24 }
25
26 /// Optional. App process that registered the item.
27 #[inline(always)]
28 pub fn app(&self) -> Option<Process<'a>> {
29 // Safety: 'a tied to self, object obtained through ES
30 let process = unsafe { self.raw.app()? };
31 Some(Process::new(process, self.version))
32 }
33
34 /// BTM launch item.
35 #[inline(always)]
36 pub fn item(&self) -> BtmLaunchItem<'a> {
37 // Safety: 'a tied to self, object obtained through ES
38 BtmLaunchItem::new(unsafe { self.raw.item() })
39 }
40}
41
42// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
43unsafe impl Send for EventBtmLaunchItemRemove<'_> {}
44// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
45unsafe impl Sync for EventBtmLaunchItemRemove<'_> {}
46
47impl_debug_eq_hash_with_functions!(EventBtmLaunchItemRemove<'a>; instigator, app, item);