endpoint_sec/event/event_dup.rs
1//! [`EventDup`]
2
3use endpoint_sec_sys::es_event_dup_t;
4
5use crate::File;
6
7/// Duplicate a file descriptor event.
8#[doc(alias = "es_event_dup_t")]
9pub struct EventDup<'a> {
10 /// Raw event
11 pub(crate) raw: &'a es_event_dup_t,
12}
13
14impl<'a> EventDup<'a> {
15 /// Describes the file the duplicated file descriptor points to.
16 #[inline(always)]
17 pub fn target(&self) -> File<'a> {
18 // Safety: 'a tied to self, object obtained through ES
19 File::new(unsafe { self.raw.target() })
20 }
21}
22
23// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
24unsafe impl Send for EventDup<'_> {}
25// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
26unsafe impl Sync for EventDup<'_> {}
27
28impl_debug_eq_hash_with_functions!(EventDup<'a>; target);