Skip to main content

ServiceRegistrationBuilder

Struct ServiceRegistrationBuilder 

Source
pub struct ServiceRegistrationBuilder { /* private fields */ }
Expand description

Builder for DNS-SD service registrations.

See RFC 6763 for details on the semantics of the various parameters.

Implementations§

Source§

impl ServiceRegistrationBuilder

Source

pub fn new(service_type: impl AsRef<str>, port: u16) -> Self

Initializes a new service registration builder with the given service type and port.

  • service_type: The service type followed by the protocol, separated by a dot (e.g. _ftp._tcp). The service type must be an underscore, followed by 1-15 characters, which may be letters, digits, or hyphens. The transport protocol must be _tcp or _udp. New service types should be registered at http://www.dns-sd.org/ServiceTypes.html.

  • port: The UDP/TCP port on which the service accepts connections.

    Pass 0 for a “placeholder” service (i.e. a service that will not be discovered by browsing, but will cause a name conflict if another client tries to register that same name). Most clients will not use placeholder services.

Source

pub fn name(&mut self, name: impl AsRef<str>) -> &mut Self

Specifies the service name to be registered.

Most applications will not specify a name, in which case the computer name is used. If a name is specified, it must be 1-63 bytes of UTF-8 text.

Source

pub fn add_txt_record_key_empty(&mut self, key: impl AsRef<str>) -> &mut Self

Adds a TXT record key to the service registration, with an empty value.

Source

pub fn add_txt_record_key_string( &mut self, key: impl AsRef<str>, value: impl AsRef<str>, ) -> &mut Self

Adds a TXT record key/value pair to the service registration.

Windows limitation: if value is an empty string, it will be treated as a key-only pair.

Source

pub fn add_txt_record_key_binary( &mut self, key: impl AsRef<str>, value: impl AsRef<[u8]>, ) -> &mut Self

Adds a TXT record key/value pair to the service registration, with a binary value.

Source

pub fn interface_index(&mut self, index: NonZeroU32) -> &mut Self

Specifies the interface on which to register the service (the index for a given interface is determined via the if_nametoindex() family of calls.)

Most applications will not specify an interface, instead automatically registering on all available interfaces.

Source

pub fn host(&mut self, host: impl AsRef<str>) -> &mut Self

Set the SRV target host name.

Most applications will not specify a host, instead automatically using the machine’s default host name(s).

Note that specifying a host does NOT create an address record for that host.

Source

pub fn domain(&mut self, domain: impl AsRef<str>) -> &mut Self

Set the domain on which to advertise the service.

Most applications will not specify a domain, instead automatically registering in the default domain(s).

Source

pub async fn register( &self, ) -> Result<ServiceRegistration, ServiceRegistrationError>

Registers the service with the system, making it discoverable by remote clients.

Trait Implementations§

Source§

impl Clone for ServiceRegistrationBuilder

Source§

fn clone(&self) -> ServiceRegistrationBuilder

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 ServiceRegistrationBuilder

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more