endpoint_sec/event/event_file_provider_update.rs
1//! [`EventFileProviderUpdate`]
2
3use std::ffi::OsStr;
4
5use endpoint_sec_sys::es_event_file_provider_update_t;
6
7use crate::File;
8
9/// Update file contents via the FileProvider framework event.
10#[doc(alias = "es_event_file_provider_update_t")]
11pub struct EventFileProviderUpdate<'a> {
12 /// Raw event
13 pub(crate) raw: &'a es_event_file_provider_update_t,
14}
15
16impl<'a> EventFileProviderUpdate<'a> {
17 /// The staged file that has had its contents updated.
18 #[inline(always)]
19 pub fn source(&self) -> File<'a> {
20 // Safety: 'a tied to self, object obtained through ES
21 File::new(unsafe { self.raw.source() })
22 }
23
24 /// The destination that the staged `source` file will be moved to.
25 #[inline(always)]
26 pub fn target_path(&self) -> &'a OsStr {
27 // Safety: 'a tied to self, object obtained through ES
28 unsafe { self.raw.target_path.as_os_str() }
29 }
30}
31
32// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
33unsafe impl Send for EventFileProviderUpdate<'_> {}
34// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
35unsafe impl Sync for EventFileProviderUpdate<'_> {}
36
37impl_debug_eq_hash_with_functions!(EventFileProviderUpdate<'a>; source, target_path);