endpoint_sec/event/event_fork.rs
1//! [`EventFork`]
2
3use endpoint_sec_sys::es_event_fork_t;
4
5use crate::Process;
6
7/// Fork a new process event.
8#[doc(alias = "es_event_fork_t")]
9pub struct EventFork<'a> {
10 /// The raw reference.
11 pub(crate) raw: &'a es_event_fork_t,
12
13 /// The version of the message.
14 pub(crate) version: u32,
15}
16
17impl<'a> EventFork<'a> {
18 /// The child process that was created.
19 #[inline(always)]
20 pub fn child(&self) -> Process<'a> {
21 // Safety: 'a tied to self, object obtained through ES
22 Process::new(unsafe { self.raw.child() }, self.version)
23 }
24}
25
26// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
27unsafe impl Send for EventFork<'_> {}
28// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
29unsafe impl Sync for EventFork<'_> {}
30
31impl_debug_eq_hash_with_functions!(EventFork<'a> with version; child);