#[non_exhaustive]pub struct ServiceRecords { /* private fields */ }Expand description
Records advertised by a single registered service.
Implementations§
Source§impl ServiceRecords
impl ServiceRecords
Sourcepub fn new(
service_type: Name,
instance: Name,
host: Name,
port: u16,
ttl_secs: u32,
) -> ServiceRecords
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.
Sourcepub fn service_type(&self) -> &Name
pub fn service_type(&self) -> &Name
The DNS-SD service type (PTR owner), e.g. _ipp._tcp.local..
Sourcepub fn a_addrs_slice(&self) -> &[Ipv4Addr]
pub fn a_addrs_slice(&self) -> &[Ipv4Addr]
Slice of IPv4 addresses.
Sourcepub fn aaaa_addrs_slice(&self) -> &[Ipv6Addr]
pub fn aaaa_addrs_slice(&self) -> &[Ipv6Addr]
Slice of IPv6 addresses.
Sourcepub fn aaaa_scopes_slice(&self) -> &[u32]
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.
Sourcepub fn txt_segments(&self) -> impl Iterator<Item = &[u8]>
pub fn txt_segments(&self) -> impl Iterator<Item = &[u8]>
TXT segments as an iterator over byte slices.
Sourcepub fn add_a(&mut self, addr: Ipv4Addr) -> &mut ServiceRecords
pub fn add_a(&mut self, addr: Ipv4Addr) -> &mut ServiceRecords
Append an IPv4 address.
Sourcepub fn add_aaaa(&mut self, addr: Ipv6Addr) -> &mut ServiceRecords
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.
Sourcepub fn add_aaaa_scoped(
&mut self,
addr: Ipv6Addr,
scope_id: u32,
) -> &mut ServiceRecords
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.
Sourcepub fn add_txt_segment(&mut self, segment: Vec<u8>) -> &mut ServiceRecords
pub fn add_txt_segment(&mut self, segment: Vec<u8>) -> &mut ServiceRecords
Append a TXT segment.
Sourcepub fn subtype_names(&self) -> &[Name]
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).
Sourcepub fn add_subtype(
&mut self,
subtype: &str,
) -> Result<&mut ServiceRecords, NameError>
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).
Sourcepub fn set_priority(&mut self, v: u16) -> &mut ServiceRecords
pub fn set_priority(&mut self, v: u16) -> &mut ServiceRecords
Set SRV priority.
Sourcepub fn set_weight(&mut self, v: u16) -> &mut ServiceRecords
pub fn set_weight(&mut self, v: u16) -> &mut ServiceRecords
Set SRV weight.
Sourcepub fn set_ttl_secs(&mut self, v: u32) -> &mut ServiceRecords
pub fn set_ttl_secs(&mut self, v: u32) -> &mut ServiceRecords
Set TTL in seconds.
Sourcepub fn set_instance(&mut self, name: Name) -> &mut ServiceRecords
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
impl Clone for ServiceRecords
Source§fn clone(&self) -> ServiceRecords
fn clone(&self) -> ServiceRecords
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServiceRecords
impl Debug for ServiceRecords
impl Eq for ServiceRecords
Source§impl PartialEq for ServiceRecords
impl PartialEq for ServiceRecords
Source§fn eq(&self, other: &ServiceRecords) -> bool
fn eq(&self, other: &ServiceRecords) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ServiceRecords
Auto Trait Implementations§
impl Freeze for ServiceRecords
impl RefUnwindSafe for ServiceRecords
impl Send for ServiceRecords
impl Sync for ServiceRecords
impl Unpin for ServiceRecords
impl UnsafeUnpin for ServiceRecords
impl UnwindSafe for ServiceRecords
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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