dbus_server_address_parser/nonce_tcp.rs
1use crate::{Family, Guid};
2
3/// This represents a DBus server address with the prefix [`nonce-tcp:`].
4///
5/// [`nonce-tcp:`]: https://dbus.freedesktop.org/doc/dbus-specification.html#transports-nonce-tcp-sockets
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct NonceTcp {
8 /// DNS name or IP address.
9 pub host: Option<String>,
10 /// The interface on which the server will listen to.
11 pub bind: Option<String>,
12 /// The TCP port the server will open or the client will connect to.
13 pub port: Option<u16>,
14 /// The type of socket family.
15 pub family: Option<Family>,
16 /// File location containing the secret.
17 pub noncefile: Option<String>,
18 /// The GUID of the Address.
19 pub guid: Option<Guid>,
20}
21
22impl NonceTcp {
23 pub fn is_connectable(&self) -> bool {
24 if let Some(port) = self.port {
25 port != 0 && self.host.is_some() && self.noncefile.is_some()
26 } else {
27 false
28 }
29 }
30
31 pub fn is_listenable(&self) -> bool {
32 true
33 }
34}