endpoint_sec/event/
event_btm_launch_item_add.rs1use std::ffi::OsStr;
4
5use endpoint_sec_sys::{es_btm_item_type_t, es_btm_launch_item_t, es_event_btm_launch_item_add_t, uid_t};
6
7use crate::Process;
8
9#[doc(alias = "es_event_btm_launch_item_add_t")]
11pub struct EventBtmLaunchItemAdd<'a> {
12 pub(crate) raw: &'a es_event_btm_launch_item_add_t,
14 pub(crate) version: u32,
16}
17
18impl<'a> EventBtmLaunchItemAdd<'a> {
19 #[inline(always)]
22 pub fn instigator(&self) -> Option<Process<'a>> {
23 let process = unsafe { self.raw.instigator()? };
25 Some(Process::new(process, self.version))
26 }
27
28 #[inline(always)]
30 pub fn app(&self) -> Option<Process<'a>> {
31 let process = unsafe { self.raw.app()? };
33 Some(Process::new(process, self.version))
34 }
35
36 #[inline(always)]
38 pub fn item(&self) -> BtmLaunchItem<'a> {
39 BtmLaunchItem::new(unsafe { self.raw.item() })
41 }
42
43 #[inline(always)]
46 pub fn executable_path(&self) -> &'a OsStr {
47 unsafe { self.raw.executable_path.as_os_str() }
49 }
50}
51
52unsafe impl Send for EventBtmLaunchItemAdd<'_> {}
54unsafe impl Sync for EventBtmLaunchItemAdd<'_> {}
56
57impl_debug_eq_hash_with_functions!(
58 EventBtmLaunchItemAdd<'a>;
59 instigator, app, item, executable_path,
60);
61
62#[doc(alias = "es_btm_launch_item_t")]
64pub struct BtmLaunchItem<'a> {
65 pub(crate) raw: &'a es_btm_launch_item_t,
67}
68
69impl<'a> BtmLaunchItem<'a> {
70 #[inline(always)]
72 pub(crate) fn new(raw: &'a es_btm_launch_item_t) -> Self {
73 Self { raw }
74 }
75
76 #[inline(always)]
78 pub fn item_type(&self) -> es_btm_item_type_t {
79 self.raw.item_type
80 }
81
82 #[inline(always)]
84 pub fn legacy(&self) -> bool {
85 self.raw.legacy
86 }
87
88 #[inline(always)]
90 pub fn managed(&self) -> bool {
91 self.raw.managed
92 }
93
94 #[inline(always)]
96 pub fn uid(&self) -> uid_t {
97 self.raw.uid
98 }
99
100 #[inline(always)]
104 pub fn item_url(&self) -> &'a OsStr {
105 unsafe { self.raw.item_url.as_os_str() }
107 }
108
109 #[inline(always)]
111 pub fn app_url(&self) -> &'a OsStr {
112 unsafe { self.raw.app_url.as_os_str() }
114 }
115}
116
117unsafe impl Send for BtmLaunchItem<'_> {}
119
120impl_debug_eq_hash_with_functions!(
121 BtmLaunchItem<'a>;
122 item_type, legacy, managed, uid, item_url, app_url,
123);