#[non_exhaustive]pub struct BrokerEndpoint {
pub broker_type: BrokerType,
pub host: String,
pub port: u16,
pub server: Option<String>,
pub device_id: Option<String>,
pub addrs: Vec<ScopedAddr>,
pub instance: Option<String>,
}alloc only.Expand description
A broker to connect to, discovered or configured.
Built with from_instance,
configured or from_url.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.broker_type: BrokerTypeThe transport.
host: StringThe TXT broker value, else the SRV target, without a trailing dot
(ebus.py:599-614); the configured URL’s host for a configured broker.
port: u16The port.
server: Option<String>The SRV target, without a trailing dot.
device_id: Option<String>The TXT device_id value, as advertised.
addrs: Vec<ScopedAddr>The advertised addresses worth trying, in candidate order
(candidate_addresses).
instance: Option<String>The instance name; None for a configured broker.
Implementations§
Source§impl BrokerEndpoint
impl BrokerEndpoint
Sourcepub fn from_instance(instance: &Instance) -> Option<Self>
pub fn from_instance(instance: &Instance) -> Option<Self>
The endpoint a browsed broker instance gives (ebus.py:598-614): host
is the TXT broker value, trimmed and with one trailing dot removed,
else the SRV target; port 0 becomes the type’s default port. None
for an instance that is not a broker type.
Sourcepub fn from_url(url: &str) -> Result<Self, UrlError>
pub fn from_url(url: &str) -> Result<Self, UrlError>
A configured broker from an mqtt:// or mqtts:// URL
(ebus.py:616-633): the port defaults to 1883 or 8883, and the host is
lowercased, as python’s urlsplit gives it, except an IPv6 zone.
Sourcepub fn configured(broker_type: BrokerType, host: &str, port: u16) -> Self
pub fn configured(broker_type: BrokerType, host: &str, port: u16) -> Self
A configured broker of broker_type at host and port.
Sourcepub fn url(&self) -> String
pub fn url(&self) -> String
scheme://host:port, with an IPv6 host in brackets (ebus.py:592-596).
Sourcepub fn connect_host(&self) -> Cow<'_, str>
pub fn connect_host(&self) -> Cow<'_, str>
The host to connect to: host when it is not a .local name, else the
first IPv4 candidate address, else host, for TLS and plain transports
alike.
Sourcepub fn device_ids(&self) -> Vec<String>
pub fn device_ids(&self) -> Vec<String>
The TXT device_id items.