endpoint_sec/event/event_lw_session_login.rs
1//! [`EventLwSessionLogin`]
2
3use std::ffi::OsStr;
4
5use endpoint_sec_sys::{es_event_lw_session_login_t, es_graphical_session_id_t};
6
7/// LoginWindow has logged in a user.
8#[doc(alias = "es_event_lw_session_login_t")]
9pub struct EventLwSessionLogin<'a> {
10 /// Raw event
11 pub(crate) raw: &'a es_event_lw_session_login_t,
12}
13
14impl<'a> EventLwSessionLogin<'a> {
15 /// Short username of the user.
16 #[inline(always)]
17 pub fn username(&self) -> &'a OsStr {
18 // Safety: 'a tied to self, object obtained through ES
19 unsafe { self.raw.username.as_os_str() }
20 }
21
22 /// Graphical session id of the session.
23 #[inline(always)]
24 pub fn graphical_session_id(&self) -> es_graphical_session_id_t {
25 self.raw.graphical_session_id
26 }
27}
28
29// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
30unsafe impl Send for EventLwSessionLogin<'_> {}
31// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
32unsafe impl Sync for EventLwSessionLogin<'_> {}
33
34impl_debug_eq_hash_with_functions!(EventLwSessionLogin<'a>; username, graphical_session_id);