endpoint_sec/event/event_proc_check.rs
1//! [`EventProcCheck`]
2
3use endpoint_sec_sys::{es_event_proc_check_t, es_proc_check_type_t};
4
5use crate::Process;
6
7/// Access control check for retrieving process information.
8#[doc(alias = "es_event_proc_check_t")]
9pub struct EventProcCheck<'a> {
10 /// Raw reference
11 pub(crate) raw: &'a es_event_proc_check_t,
12 /// Message version
13 pub(crate) version: u32,
14}
15
16impl<'a> EventProcCheck<'a> {
17 /// Process for which the access will be checked.
18 #[inline(always)]
19 pub fn target(&self) -> Option<Process<'a>> {
20 Some(Process::new(
21 // Safety: 'a tied to self, object obtained through ES
22 unsafe { self.raw.target() }?,
23 self.version,
24 ))
25 }
26
27 /// Type of call number used to check the access on the target process.
28 #[inline(always)]
29 pub fn type_(&self) -> es_proc_check_type_t {
30 self.raw.type_
31 }
32
33 /// Flavor used to check the access on the target process.
34 #[inline(always)]
35 pub fn flavor(&self) -> i32 {
36 self.raw.flavor
37 }
38}
39
40// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
41unsafe impl Send for EventProcCheck<'_> {}
42// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
43unsafe impl Sync for EventProcCheck<'_> {}
44
45impl_debug_eq_hash_with_functions!(EventProcCheck<'a> with version; target, type_, flavor);