Skip to main content

Advertisement

Struct Advertisement 

Source
#[non_exhaustive]
pub struct Advertisement { pub identity: Identity, pub instance: Option<String>, pub ebus_port: Option<u16>, pub device_info_port: u16, pub http: Vec<HttpService>, pub brokers: Vec<BrokerService>, }
Available on crate feature alloc only.
Expand description

Everything a host advertises, all under one instance name.

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.
§identity: Identity

The identity.

§instance: Option<String>

The instance name; None for the default rule (Advertisement::instance_names).

§ebus_port: Option<u16>

The _ebus._tcp port; None for the first REST API’s port, else 0.

§device_info_port: u16

The _device-info._tcp port, 0 by default.

§http: Vec<HttpService>

REST APIs.

§brokers: Vec<BrokerService>

Brokers, at most one per type.

Implementations§

Source§

impl Advertisement

Source

pub fn new(identity: Identity) -> Self

The identity’s _ebus._tcp and _device-info._tcp records alone.

Source

pub fn instance(self, name: &str) -> Self

With an explicit instance name.

Source

pub fn http(self, http: HttpService) -> Self

With a REST API added.

Source

pub fn broker(self, broker: BrokerService) -> Self

With a broker added.

Source

pub fn records(&self, server: &str) -> Result<Vec<ServiceRecord>, TxtError>

Every record, in python’s order (_mdns_core.py:900-939): _ebus._tcp, _device-info._tcp, the REST APIs, then the brokers. server is the SRV target, the default TXT broker. Every record is checked with check_txt; brokers without the broker-host role are logged with reason=brokersWithoutBrokerHostRole and roles is left as given.

Source

pub fn base_instance_name(&self, server: &str) -> String

The instance name all records share: the explicit name, else the first device id when it fits MAX_DEFAULT_INSTANCE_OCTETS, else the host label of server, logged with reason=deviceIdTooLongForInstanceName (_mdns_core.py:1129-1152).

Source

pub fn instance_names( &self, server: &str, ) -> impl Iterator<Item = String> + use<>

The instance names to try in turn: the base name (Advertisement::base_instance_name), then -2 through -99 (_mdns_core.py:937-939).

Trait Implementations§

Source§

impl Clone for Advertisement

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 Advertisement

Source§

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

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

impl Eq for Advertisement

Source§

impl PartialEq for Advertisement

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 Advertisement

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.