Struct mdns_sd::ServiceInfo

source ·
pub struct ServiceInfo { /* private fields */ }
Expand description

Complete info about a Service Instance.

We can construct some PTR, one SRV and one TXT record from this info, as well as A (IPv4 Address) records.

Implementations§

source§

impl ServiceInfo

source

pub fn new<Ip: AsIpv4Addrs, P: IntoTxtProperties>( ty_domain: &str, my_name: &str, host_name: &str, host_ipv4: Ip, port: u16, properties: P ) -> Result<Self>

Creates a new service info.

ty_domain is the service type and the domain label, for example “_my-service._udp.local.”.

my_name is the instance name, without the service type suffix.

properties can be None or key/value string pairs, in a type that implements IntoTxtProperties trait. It supports:

  • HashMap<String, String>
  • Option<HashMap<String, String>>
  • slice of tuple: &[(K, V)] where K and V are std::string::ToString.

host_ipv4 can be one or more IPv4 addresses, in a type that implements AsIpv4Addrs trait. It supports:

  • Single IPv4: "192.168.0.1"
  • Multiple IPv4 separated by comma: "192.168.0.1,192.168.0.2"
  • A slice of IPv4: &["192.168.0.1", "192.168.0.2"]
  • All the above formats with Ipv4Addr or String instead of &str.

The host TTL and other TTL are set to default values.

source

pub fn enable_addr_auto(self) -> Self

Indicates that the library should automatically update the addresses of this service, when IPv4 address(es) are added or removed on the host.

source

pub fn is_addr_auto(&self) -> bool

Returns if the service’s addresses will be updated automatically when the host IPv4 addrs change.

source

pub fn get_type(&self) -> &str

Returns the service type including the domain label.

For example: “_my-service._udp.local.”.

source

pub fn get_subtype(&self) -> &Option<String>

Returns the service subtype including the domain label, if subtype has been defined.

For example: “_printer._sub._http._tcp.local.”.

source

pub fn get_fullname(&self) -> &str

Returns a reference of the service fullname.

This is useful, for example, in unregister.

source

pub fn get_properties(&self) -> &TxtProperties

Returns the properties from TXT records.

source

pub fn get_property(&self, key: &str) -> Option<&TxtProperty>

Returns a property for a given key, where key is case insensitive.

Returns None if key does not exist.

source

pub fn get_property_val(&self, key: &str) -> Option<Option<&[u8]>>

Returns a property value for a given key, where key is case insensitive.

Returns None if key does not exist.

source

pub fn get_property_val_str(&self, key: &str) -> Option<&str>

Returns a property value string for a given key, where key is case insensitive.

Returns None if key does not exist.

source

pub fn get_hostname(&self) -> &str

Returns the service’s hostname.

source

pub fn get_port(&self) -> u16

Returns the service’s port.

source

pub fn get_addresses(&self) -> &HashSet<Ipv4Addr>

Returns the service’s addresses

source

pub fn get_host_ttl(&self) -> u32

Returns the service’s TTL used for SRV and Address records.

source

pub fn get_other_ttl(&self) -> u32

Returns the service’s TTL used for PTR and TXT records.

source

pub fn get_priority(&self) -> u16

Returns the service’s priority used in SRV records.

source

pub fn get_weight(&self) -> u16

Returns the service’s weight used in SRV records.

Trait Implementations§

source§

impl Clone for ServiceInfo

source§

fn clone(&self) -> ServiceInfo

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for ServiceInfo

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.