Skip to main content

endpoint_sec/event/
event_get_task_name.rs

1//! [`EventGetTaskName`]
2
3use endpoint_sec_sys::{es_event_get_task_name_t, es_get_task_type_t};
4
5use crate::Process;
6
7/// Get a process's task name port
8#[doc(alias = "es_event_get_task_name_t")]
9pub struct EventGetTaskName<'a> {
10    /// Raw reference
11    pub(crate) raw: &'a es_event_get_task_name_t,
12    /// Message version
13    pub(crate) version: u32,
14}
15
16impl<'a> EventGetTaskName<'a> {
17    /// Process for which the task name port will be retrieved.
18    #[inline(always)]
19    pub fn target(&self) -> Process<'a> {
20        // Safety: 'a tied to self, object obtained through ES
21        Process::new(unsafe { self.raw.target() }, self.version)
22    }
23
24    /// Indicates how the process is obtaining the task for the target process.
25    ///
26    /// Note: only available if message version >= 5.
27    #[inline(always)]
28    pub fn type_(&self) -> Option<es_get_task_type_t> {
29        if self.version < 5 {
30            None
31        } else {
32            Some(self.raw.type_)
33        }
34    }
35}
36
37// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
38unsafe impl Send for EventGetTaskName<'_> {}
39// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
40unsafe impl Sync for EventGetTaskName<'_> {}
41
42impl_debug_eq_hash_with_functions!(EventGetTaskName<'a> with version; target, type_);