endpoint_sec/event/event_proc_suspend_resume.rs
1//! [`EventProcSuspendResume`]
2
3use endpoint_sec_sys::{es_event_proc_suspend_resume_t, es_proc_suspend_resume_type_t};
4
5use crate::Process;
6
7/// One of `pid_suspend()`, `pid_resume()` or `pid_shutdown_sockets()` is being called on a process.
8#[doc(alias = "es_event_proc_suspend_resume_t")]
9pub struct EventProcSuspendResume<'a> {
10 /// Raw reference
11 pub(crate) raw: &'a es_event_proc_suspend_resume_t,
12 /// Message version
13 pub(crate) version: u32,
14}
15
16impl<'a> EventProcSuspendResume<'a> {
17 /// Process that is being suspended, resumed or is the object of a `pid_shutdown_sockets()` call.
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 operation called on the target process.
28 #[inline(always)]
29 pub fn type_(&self) -> es_proc_suspend_resume_type_t {
30 self.raw.type_
31 }
32}
33
34// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
35unsafe impl Send for EventProcSuspendResume<'_> {}
36// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
37unsafe impl Sync for EventProcSuspendResume<'_> {}
38
39impl_debug_eq_hash_with_functions!(EventProcSuspendResume<'a> with version; target, type_);