pub trait Discovery:
Debug
+ Send
+ Sync
+ 'static {
// Provided methods
fn publish(&self, _data: &EndpointData) { ... }
fn resolve(
&self,
_endpoint_id: EndpointId,
) -> Option<BoxStream<Result<DiscoveryItem, DiscoveryError>>> { ... }
}Expand description
Endpoint discovery for super::Endpoint.
This trait defines publishing and resolving addressing information for a EndpointId.
This enables connecting to other endpoints with only knowing the EndpointId, by using this
Discovery system to look up the actual addressing information. It is common for
implementations to require each endpoint to publish their own information before it can be
looked up by other endpoints.
The published addressing information can include both a RelayUrl and/or direct
addresses. See EndpointData for details.
To allow for discovery, the super::Endpoint will call publish whenever
discovery information changes. If a discovery mechanism requires a periodic
refresh, it should start its own task.
Provided Methods§
Sourcefn publish(&self, _data: &EndpointData)
fn publish(&self, _data: &EndpointData)
Publishes the given EndpointData to the discovery mechanism.
This is fire and forget, since the Endpoint can not wait for successful
publishing. If publishing is async, the implementation should start it’s own task.
This will be called from a tokio task, so it is safe to spawn new tasks.
These tasks will be run on the runtime of the super::Endpoint.
Sourcefn resolve(
&self,
_endpoint_id: EndpointId,
) -> Option<BoxStream<Result<DiscoveryItem, DiscoveryError>>>
fn resolve( &self, _endpoint_id: EndpointId, ) -> Option<BoxStream<Result<DiscoveryItem, DiscoveryError>>>
Resolves the DiscoveryItem for the given EndpointId.
Once the returned [BoxStream] is dropped, the service should stop any pending
work.
Implementations on Foreign Types§
Source§impl<T: Discovery> Discovery for Arc<T>
impl<T: Discovery> Discovery for Arc<T>
fn publish(&self, data: &EndpointData)
fn resolve( &self, endpoint_id: EndpointId, ) -> Option<BoxStream<Result<DiscoveryItem, DiscoveryError>>>
Implementors§
impl Discovery for DnsDiscovery
wasm_browser only.impl Discovery for MdnsDiscovery
discovery-local-network only.impl Discovery for DhtDiscovery
discovery-pkarr-dht only.