Skip to main content

BrokerSearch

Struct BrokerSearch 

Source
pub struct BrokerSearch { /* private fields */ }
Available on crate feature alloc only.
Expand description

One broker search, with no I/O: the backend’s sightings and the time go in; requeries and, once, the result come out.

The browse covers every broker type, so a broker of a type not accepted is logged with reason=brokerTransportNotAccepted, and a broker wanted by device id is found under an accepted transport when only another of its transports carries the id. The result is set settle_ms after a usable broker is first seen, so each broker’s every transport has been heard and the one earliest in BrokerConfig::accepted is chosen; in DiscoveryWithFallback with a URL, the configured broker becomes the result fallback_after_ms after the start when no usable broker is pending. While no usable broker is seen, BrokerSearch::poll_requery asks for a requery 3 s, 6 s and 36 s after the start, then every 30 s. Once set, the result never changes.

Implementations§

Source§

impl BrokerSearch

Source

pub fn new(now: Instant, cfg: BrokerConfig) -> Result<Self, BrokerConfigError>

A search starting at now. In ConfiguredOnly the result is the configured broker at once.

Source

pub fn browses(&self) -> bool

False in ConfiguredOnly: no browse runs.

Source

pub fn mode(&self) -> BrokerMode

The mode in effect.

Source

pub fn browse_types(&self) -> &'static [BrokerType]

The service types to browse: every broker type.

Source

pub fn handle(&mut self, now: Instant, s: Sighting)

Apply a backend report.

Source

pub fn handle_timeout(&mut self, now: Instant)

Advance to now: settle, fall back or schedule a requery when due.

Source

pub fn poll_requery(&mut self) -> bool

True once per requery the search asks the backend for.

Source

pub fn poll_timeout(&self) -> Option<Instant>

The next instant BrokerSearch::handle_timeout has work at.

Source

pub fn result(&self) -> Option<&BrokerEndpoint>

The broker chosen, set once and then fixed.

Source

pub fn candidates(&self) -> Vec<BrokerEndpoint>

The accepted brokers now seen, with wanted applied, ranked.

Trait Implementations§

Source§

impl Clone for BrokerSearch

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 BrokerSearch

Source§

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

Formats the value using the given formatter. Read more

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.