dbus_server_address_parser/
tcp.rs

1use crate::{Family, Guid};
2
3/// This represents a DBus server address with the prefix [`tcp:`].
4///
5/// [`tcp:`]: https://dbus.freedesktop.org/doc/dbus-specification.html#transports-tcp-sockets
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct Tcp {
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    /// Is the family key/value pair.
15    pub family: Option<Family>,
16    /// The GUID of the Address.
17    pub guid: Option<Guid>,
18}
19
20impl Tcp {
21    pub fn is_connectable(&self) -> bool {
22        if let Some(port) = self.port {
23            port != 0 && self.host.is_some()
24        } else {
25            false
26        }
27    }
28
29    pub fn is_listenable(&self) -> bool {
30        true
31    }
32}