Skip to main content

ServiceRecords

Struct ServiceRecords 

Source
#[non_exhaustive]
pub struct ServiceRecords { /* private fields */ }
Expand description

Records advertised by a single registered service.

Implementations§

Source§

impl ServiceRecords

Source

pub fn new( service_type: Name, instance: Name, host: Name, port: u16, ttl_secs: u32, ) -> ServiceRecords

Construct a new record bundle with the required fields. Optional fields (records, txt, priority, weight) start empty/default.

service_type is the DNS-SD PTR owner, e.g. _ipp._tcp.local.. It must be the parent label sequence of instance.

Source

pub fn service_type(&self) -> &Name

The DNS-SD service type (PTR owner), e.g. _ipp._tcp.local..

Source

pub fn instance(&self) -> &Name

The instance name (e.g. MyPrinter._ipp._tcp.local.).

Source

pub fn host(&self) -> &Name

The SRV target hostname.

Source

pub const fn port(&self) -> u16

The service port.

Source

pub const fn priority(&self) -> u16

SRV priority field.

Source

pub const fn weight(&self) -> u16

SRV weight field.

Source

pub const fn ttl_secs(&self) -> u32

Record TTL in seconds.

Source

pub fn a_addrs_slice(&self) -> &[Ipv4Addr]

Slice of IPv4 addresses.

Source

pub fn aaaa_addrs_slice(&self) -> &[Ipv6Addr]

Slice of IPv6 addresses.

Source

pub fn aaaa_scopes_slice(&self) -> &[u32]

Slice of per-AAAA interface scope ids (one entry per AAAA address; parallel to Self::aaaa_addrs_slice). A scope of 0 means “unscoped / any interface” — appropriate for global addresses or when the caller does not know which interface the link-local will be published on.

Used by Endpoint to disambiguate IPv6 link-local self-loopback on multi-homed hosts.

Source

pub fn txt_segments(&self) -> impl Iterator<Item = &[u8]>

TXT segments as an iterator over byte slices.

Source

pub fn add_a(&mut self, addr: Ipv4Addr) -> &mut ServiceRecords

Append an IPv4 address.

Source

pub fn add_aaaa(&mut self, addr: Ipv6Addr) -> &mut ServiceRecords

Append an IPv6 address with an unspecified interface scope.

Equivalent to Self::add_aaaa_scoped with scope_id = 0. For link-local addresses on multi-homed hosts prefer Self::add_aaaa_scoped so self-loopback detection can distinguish your own packets from peer packets that share the same numeric link-local on another interface.

Source

pub fn add_aaaa_scoped( &mut self, addr: Ipv6Addr, scope_id: u32, ) -> &mut ServiceRecords

Append an IPv6 address bound to a specific interface scope.

scope_id is typically the receiving interface index (the same value the host’s if_nametoindex(3) returns). Endpoint::handle matches self-loopback for link-local sources by (address, scope) so a peer’s identical link-local on a different interface is NOT misclassified as self.

A scope_id of 0 keeps the legacy behaviour (matches any interface). For global / unique-local IPv6 the scope is effectively ignored.

Source

pub fn add_txt_segment(&mut self, segment: Vec<u8>) -> &mut ServiceRecords

Append a TXT segment.

Source

pub fn subtype_names(&self) -> &[Name]

The RFC 6763 §7.1 subtype browse names registered for this service (each the full <subtype>._sub.<service_type> form).

Source

pub fn add_subtype( &mut self, subtype: &str, ) -> Result<&mut ServiceRecords, NameError>

Register a DNS-SD subtype (RFC 6763 §7.1). subtype is the subtype label (e.g. "_printer"); the full browse name <subtype>._sub.<service_type> is derived from the current service type and stored. The service then advertises a shared PTR <browse_name> -> instance and answers browse queries for it.

Returns a NameError if the derived <subtype>._sub.<service_type> is not a valid DNS name (e.g. an over-long label or total length).

Source

pub fn set_priority(&mut self, v: u16) -> &mut ServiceRecords

Set SRV priority.

Source

pub fn set_weight(&mut self, v: u16) -> &mut ServiceRecords

Set SRV weight.

Source

pub fn set_ttl_secs(&mut self, v: u32) -> &mut ServiceRecords

Set TTL in seconds.

Source

pub fn set_instance(&mut self, name: Name) -> &mut ServiceRecords

Replace the instance name (used during conflict-driven rename).

Trait Implementations§

Source§

impl Clone for ServiceRecords

Source§

fn clone(&self) -> ServiceRecords

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 ServiceRecords

Source§

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

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

impl Eq for ServiceRecords

Source§

impl PartialEq for ServiceRecords

Source§

fn eq(&self, other: &ServiceRecords) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ServiceRecords

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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