heim_host/os/
windows.rs

1//! Windows-specific extensions.
2
3use std::net::IpAddr;
4
5/// Extension for [User] struct.
6///
7/// [User]: ../../struct.User.html
8pub trait UserExt {
9    /// Domain name that the user belongs to.
10    fn domain(&self) -> &str;
11
12    // TODO: Not all possible protocols are supported at the moment by the sys impl.
13    // When they are will be implemented fully, this function should return `&IpAddr` directly,
14    // without `Option<T>` wrapper.
15    // See https://github.com/heim-rs/heim/issues/63
16    /// Client network address of a RDP session.
17    ///
18    /// At the moment not all possible protocols are supported
19    /// (`AF_IPX`, `AF_NETBIOS` and `AF_UNSPEC` families are missing),
20    /// and therefore, this method returns `Option<&IpAddr>`.
21    ///
22    /// It should be expected that method will return `&IpAddr` directly,
23    /// when support for all protocols will arrive.
24    fn address(&self) -> Option<&IpAddr>;
25}
26
27#[cfg(target_os = "windows")]
28impl UserExt for crate::User {
29    fn domain(&self) -> &str {
30        self.as_ref().domain()
31    }
32
33    fn address(&self) -> Option<&IpAddr> {
34        self.as_ref().address()
35    }
36}