Skip to main content

ServiceInfo

Struct ServiceInfo 

Source
pub struct ServiceInfo<'a, const LLEN: usize = 4> { /* private fields */ }
Expand description

Information about a service to declare over mDNS.

Implementations§

Source§

impl<'a, const LLEN: usize> ServiceInfo<'a, LLEN>

Source

pub fn new( service_type: &'a str, instance_name: &'a str, hostname: &'a str, ip_address: impl Into<IpAddr>, netmask: impl Into<IpAddr>, port: u16, ) -> Self

Creates information about a new service.

use opslag::ServiceInfo;

let info = ServiceInfo::<4>::new(
   "_my-service._udp.local", // Name of my service, same for all nodes
   "instance01",             // This specific service instance
   "nugget.local",           // My host name (<some_name>.local)
   [192, 168, 0, 3],         // The IP for my host name
   [255, 255, 255, 0],       // Netmask for the IP
   1234,                     // The port the service is running on
);
Source

pub fn service_type(&self) -> &Label<'a, LLEN>

The type of service.

Example: _my-service._tcp.local

Source

pub fn instance_name(&self) -> &Label<'a, LLEN>

The instance name.

Example: myinstance01

Source

pub fn hostname(&self) -> &Label<'a, LLEN>

The host name the service is running on.

Example: Martin's Macbook Air.local

Source

pub fn ip_address(&self) -> IpAddr

Corresponding IP address for the host name.

Example: 192.160.10.24

Source

pub fn netmask(&self) -> IpAddr

The netmask, if known.

Otherwise returns a “full” mask, ie 255.255.255.255.

Source

pub fn port(&self) -> u16

Port the service is running on.

Example: 8080

Trait Implementations§

Source§

impl<'a, const LLEN: usize> Debug for ServiceInfo<'a, LLEN>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, const LLEN: usize> Freeze for ServiceInfo<'a, LLEN>

§

impl<'a, const LLEN: usize> RefUnwindSafe for ServiceInfo<'a, LLEN>

§

impl<'a, const LLEN: usize> Send for ServiceInfo<'a, LLEN>

§

impl<'a, const LLEN: usize> Sync for ServiceInfo<'a, LLEN>

§

impl<'a, const LLEN: usize> Unpin for ServiceInfo<'a, LLEN>

§

impl<'a, const LLEN: usize> UnwindSafe for ServiceInfo<'a, LLEN>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 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.