endpoint_sec/event/
event_uipc_bind.rs

1//! [`EventUipcBind`]
2
3use std::ffi::OsStr;
4
5use endpoint_sec_sys::{es_event_uipc_bind_t, mode_t};
6
7use crate::File;
8
9/// A UNIX-domain socket is about to be bound to a path.
10#[doc(alias = "es_event_uipc_bind_t")]
11pub struct EventUipcBind<'a> {
12    /// Raw event
13    pub(crate) raw: &'a es_event_uipc_bind_t,
14}
15
16impl<'a> EventUipcBind<'a> {
17    /// Describes the directory the socket file is created in.
18    #[inline(always)]
19    pub fn dir(&self) -> File<'a> {
20        // Safety: 'a tied to self, object obtained through ES
21        File::new(unsafe { self.raw.dir() })
22    }
23
24    /// The filename of the socket file.
25    #[inline(always)]
26    pub fn filename(&self) -> &'a OsStr {
27        // Safety: 'a tied to self, object obtained through ES
28        unsafe { self.raw.filename.as_os_str() }
29    }
30
31    /// Mode of the socket file.
32    #[inline(always)]
33    pub fn mode(&self) -> mode_t {
34        self.raw.mode
35    }
36}
37
38// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
39unsafe impl Send for EventUipcBind<'_> {}
40// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
41unsafe impl Sync for EventUipcBind<'_> {}
42
43impl_debug_eq_hash_with_functions!(EventUipcBind<'a>; dir, filename, mode);