pub struct Endpoint { /* private fields */ }Expand description
Handle to a running mDNS endpoint.
Cloneable; every clone shares the same underlying driver task. The driver
task is spawned at Self::server time and exits when the last clone
(and every derived Service / Query handle) is dropped — detected
via Rc::strong_count(&inner) == 1 inside the driver loop.
Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub async fn server(opts: ServerOptions) -> Result<Self, ServerError>
pub async fn server(opts: ServerOptions) -> Result<Self, ServerError>
Bind the multicast sockets configured in opts and spawn the driver
task on the current compio runtime.
Sourcepub fn stats(&self) -> StatsSnapshot
Available on crate feature stats only.
pub fn stats(&self) -> StatsSnapshot
stats only.Return a point-in-time snapshot of the I/O + protocol counters for this endpoint.
Delegates to the shared stats::Stats instance owned by
the proto endpoint (and shared with the driver I/O paths), so the
snapshot covers wire-level rx/tx as well as protocol-level events.
Sourcepub async fn register_service(
&self,
spec: ServiceSpec,
) -> Result<Service, RegisterError>
pub async fn register_service( &self, spec: ServiceSpec, ) -> Result<Service, RegisterError>
Register a new service.
Returns a Service handle for receiving ServiceUpdate events;
dropping the handle implicitly unregisters the service. Drop encodes
the RFC 6762 §10.1 goodbye records and tears down the proto state
synchronously; the driver task then multicasts the queued TTL=0
datagrams a few times for loss resilience.
Sourcepub async fn start_query(
&self,
spec: QuerySpec,
) -> Result<Query, StartQueryError>
pub async fn start_query( &self, spec: QuerySpec, ) -> Result<Query, StartQueryError>
Start a query against the endpoint.
Returns a Query handle for receiving QueryEvent
events; dropping the handle implicitly cancels the query (the driver
removes the proto state machine on its next loop iteration).
Sourcepub async fn browse(&self, param: QueryParam) -> Result<Lookup, StartQueryError>
pub async fn browse(&self, param: QueryParam) -> Result<Lookup, StartQueryError>
Browse for instances of a DNS-SD service type, resolving each into a
ServiceEntry. See Lookup and QueryParam.
Sourcepub async fn lookup(
&self,
service: Name,
timeout: Duration,
) -> Result<Lookup, StartQueryError>
pub async fn lookup( &self, service: Name, timeout: Duration, ) -> Result<Lookup, StartQueryError>
Convenience for Self::browse with default parameters and the given
browse timeout.
Sourcepub async fn resolve_host(
&self,
host: Name,
timeout: Duration,
) -> Result<Vec<IpAddr>, StartQueryError>
pub async fn resolve_host( &self, host: Name, timeout: Duration, ) -> Result<Vec<IpAddr>, StartQueryError>
Resolve a host name to its addresses via mDNS A / AAAA queries (RFC 6762), without the DNS-SD browse/resolve chain.
Issues both queries and collects every advertised address for the
timeout window (the answer window for multicast responses), returning
them IPv4 first then IPv6, deduplicated and capped per family. The
result is empty if nothing answers. Unlike Self::resolve_instance
this does not require — or interpret — DNS-SD records; it is the
multicast analogue of resolving a hostname.
Sourcepub async fn resolve_instance(
&self,
instance: Name,
timeout: Duration,
) -> Result<Option<ServiceEntry>, StartQueryError>
pub async fn resolve_instance( &self, instance: Name, timeout: Duration, ) -> Result<Option<ServiceEntry>, StartQueryError>
Resolve a known DNS-SD service instance directly into a
ServiceEntry, skipping the PTR browse step (e.g.
Name::try_from_str("Office._ipp._tcp.local.")).
Issues SRV + TXT for the instance and A / AAAA for the SRV target host,
and returns the first complete resolution — host + port, TXT, and at
least one address — or None if it does not complete within timeout.
Use Self::browse instead when the instance names are not known in
advance.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Endpoint
impl !Send for Endpoint
impl !Sync for Endpoint
impl !UnwindSafe for Endpoint
impl Freeze for Endpoint
impl Unpin for Endpoint
impl UnsafeUnpin for Endpoint
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