pub trait Discovery: Send + Sync {
// Required methods
fn advertise(&self, service: ServiceAdvertisement) -> Result<()>;
fn withdraw(&self, service_type: &str) -> Result<()>;
fn browse(&self, service_type: &str) -> Result<Vec<DiscoveredServer>>;
}Expand description
How a service is published and how remote ones are found.
A host implements this over its mDNS library of choice; the crate decides what the record
contains and what an announcement obliges it to do, so the two stay in one place. The trait never
reports a record it has not published: advertise returning Ok means
a server can find the endpoint, and the whole server-initiated mode rests on that.
A client that advertises must not dial a server itself (connection.md, Server Initiated
Connections). This crate enforces that: connect refuses a configuration
that advertises.
Required Methods§
Sourcefn advertise(&self, service: ServiceAdvertisement) -> Result<()>
fn advertise(&self, service: ServiceAdvertisement) -> Result<()>
Publishes service until its service type is withdrawn.
§Errors
Returns an error when the record could not be published. The client then refuses to start, because accepting connections nobody can find is not the mode it was asked for.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".