Skip to main content

BrokerEndpoint

Struct BrokerEndpoint 

Source
#[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>, }
Available on crate feature 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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§broker_type: BrokerType

The transport.

§host: String

The 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: u16

The 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

Source

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.

Source

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.

Source

pub fn configured(broker_type: BrokerType, host: &str, port: u16) -> Self

A configured broker of broker_type at host and port.

Source

pub fn url(&self) -> String

scheme://host:port, with an IPv6 host in brackets (ebus.py:592-596).

Source

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.

Source

pub fn device_ids(&self) -> Vec<String>

The TXT device_id items.

Trait Implementations§

Source§

impl Clone for BrokerEndpoint

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BrokerEndpoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for BrokerEndpoint

Source§

impl Hash for BrokerEndpoint

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BrokerEndpoint

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BrokerEndpoint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.