Skip to main content

BrokerConfig

Struct BrokerConfig 

Source
#[non_exhaustive]
pub struct BrokerConfig { pub mode: Option<BrokerMode>, pub url: Option<BrokerEndpoint>, pub wanted: Option<Wanted>, pub tls: bool, pub accept: Option<Vec<BrokerType>>, pub allow_unmatched: bool, pub settle_ms: u64, pub fallback_after_ms: u64, }
Available on crate feature alloc only.
Expand description

How a host finds its broker, from its defaults overridden by its REST “MQTT broker configuration” (framework.md:93, 607).

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.
§mode: Option<BrokerMode>

The broker mode; None: ConfiguredOnly with a URL, else DiscoveryOnly.

§url: Option<BrokerEndpoint>

The configured broker.

§wanted: Option<Wanted>

The particular discovered broker wanted; not with a URL.

§tls: bool

TLS required; also implied by an mqtts:// URL.

§accept: Option<Vec<BrokerType>>

The accepted broker types in the client’s preference order, most preferred first; a type listed twice keeps its first position. None: [SecureMqtt] with TLS, else TCP_BROKER_TYPES, both in the specification’s order. A list is used as given whatever tls says, so a TLS client listing a plain type can select a plain broker.

§allow_unmatched: bool

In DiscoveryWithFallback with a URL, accept a discovered broker that does not match it (ebus.py:776-781).

§settle_ms: u64

How long after the first usable broker is seen the result is set.

§fallback_after_ms: u64

In DiscoveryWithFallback with a URL, how long after the start the configured broker is used when no discovered broker matched.

Implementations§

Source§

impl BrokerConfig

Source

pub fn effective_mode(&self) -> BrokerMode

The mode in effect: mode, else ConfiguredOnly with a URL, else DiscoveryOnly.

Source

pub fn requires_tls(&self) -> bool

True when TLS is required: tls, or a TLS URL.

Source

pub fn accepted(&self) -> Vec<BrokerType>

The broker types accepted, most preferred first: accept without repeats, else _secure-mqtt._tcp alone when TLS is required, else TCP_BROKER_TYPES (_mdns_core.py:247-253).

Source

pub fn check(&self) -> Result<(), BrokerConfigError>

The configuration errors BrokerSearch::new rejects.

Source

pub fn rank( &self, endpoints: impl IntoIterator<Item = BrokerEndpoint>, ) -> Vec<BrokerEndpoint>

The accepted brokers among endpoints, with wanted applied, ranked in the accepted order. endpoints is every broker endpoint seen, of every type: Wanted::DeviceId reads the device_id of endpoints whose type is not accepted too.

Trait Implementations§

Source§

impl Clone for BrokerConfig

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 BrokerConfig

Source§

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

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

impl Default for BrokerConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for BrokerConfig

Source§

impl PartialEq for BrokerConfig

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 BrokerConfig

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.