Skip to main content

endpoint_sec/event/
event_exchangedata.rs

1//! [`EventExchangeData`]
2
3use endpoint_sec_sys::es_event_exchangedata_t;
4
5use crate::File;
6
7/// Exchange data atomically between two files event.
8#[doc(alias = "es_event_exchangedata_t")]
9pub struct EventExchangeData<'a> {
10    /// Raw event
11    pub(crate) raw: &'a es_event_exchangedata_t,
12}
13
14impl<'a> EventExchangeData<'a> {
15    /// The first file to be exchanged.
16    #[inline(always)]
17    pub fn file1(&self) -> File<'a> {
18        // Safety: 'a tied to self, object obtained through ES
19        File::new(unsafe { self.raw.file1() })
20    }
21
22    /// The second file to be exchanged.
23    #[inline(always)]
24    pub fn file2(&self) -> File<'a> {
25        // Safety: 'a tied to self, object obtained through ES
26        File::new(unsafe { self.raw.file2() })
27    }
28}
29
30// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
31unsafe impl Send for EventExchangeData<'_> {}
32// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
33unsafe impl Sync for EventExchangeData<'_> {}
34
35impl_debug_eq_hash_with_functions!(EventExchangeData<'a>; file1, file2);