Skip to main content

endpoint_sec/event/
event_file_provider_materialize.rs

1//! [`EventFileProviderMaterialize`]
2
3use endpoint_sec_sys::es_event_file_provider_materialize_t;
4
5use crate::{File, Process};
6
7/// Materialize a file via the FileProvider framework event.
8#[doc(alias = "es_event_file_provider_materialize_t")]
9pub struct EventFileProviderMaterialize<'a> {
10    /// The raw reference.
11    pub(crate) raw: &'a es_event_file_provider_materialize_t,
12
13    /// The version of the message.
14    pub(crate) version: u32,
15}
16
17impl<'a> EventFileProviderMaterialize<'a> {
18    /// The process that instigated the materialization.
19    #[inline(always)]
20    pub fn instigator(&self) -> Process<'a> {
21        // Safety: 'a tied to self, object obtained through ES
22        Process::new(unsafe { self.raw.instigator() }, self.version)
23    }
24
25    /// The staged file that has been materialized
26    #[inline(always)]
27    pub fn source(&self) -> File<'a> {
28        // Safety: 'a tied to self, object obtained through ES
29        File::new(unsafe { self.raw.source() })
30    }
31
32    /// The destination of the staged source file.
33    #[inline(always)]
34    pub fn target(&self) -> File<'a> {
35        // Safety: 'a tied to self, object obtained through ES
36        File::new(unsafe { self.raw.target() })
37    }
38}
39
40// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
41unsafe impl Send for EventFileProviderMaterialize<'_> {}
42// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
43unsafe impl Sync for EventFileProviderMaterialize<'_> {}
44
45impl_debug_eq_hash_with_functions!(EventFileProviderMaterialize<'a> with version; instigator, source, target);