endpoint_sec/event/
event_uipc_connect.rs

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