heim_host/os/macos.rs
1//! macOS-specific extensions.
2
3use crate::Pid;
4
5/// macOS-specific extensions for [User].
6///
7/// In macOS user information is provided by `utmpx` (see `man utmpx(5)`),
8/// trait methods are representing fields of this struct.
9///
10/// [User]: ../../struct.User.html
11pub trait UserExt {
12 /// Returns the `Pid` of login process.
13 fn pid(&self) -> Pid;
14
15 /// Returns the tty or pseudo-tty name associated with user.
16 fn terminal(&self) -> &str;
17
18 /// Returns the terminal identifier.
19 fn id(&self) -> &str;
20
21 /// Returns the hostname for remote login.
22 fn hostname(&self) -> &str;
23}
24
25#[cfg(target_os = "macos")]
26impl UserExt for crate::User {
27 fn pid(&self) -> Pid {
28 self.as_ref().pid()
29 }
30
31 fn terminal(&self) -> &str {
32 self.as_ref().terminal()
33 }
34
35 fn id(&self) -> &str {
36 self.as_ref().id()
37 }
38
39 fn hostname(&self) -> &str {
40 self.as_ref().hostname()
41 }
42}