Discovery

Trait Discovery 

Source
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§

Source

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.

Source

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>

Source§

fn publish(&self, data: &EndpointData)

Source§

fn resolve( &self, endpoint_id: EndpointId, ) -> Option<BoxStream<Result<DiscoveryItem, DiscoveryError>>>

Implementors§

Source§

impl Discovery for DnsDiscovery

Available on non-wasm_browser only.
Source§

impl Discovery for MdnsDiscovery

Available on crate feature discovery-local-network only.
Source§

impl Discovery for DhtDiscovery

Available on crate feature discovery-pkarr-dht only.
Source§

impl Discovery for PkarrPublisher

Source§

impl Discovery for PkarrResolver

Source§

impl Discovery for StaticProvider

Source§

impl Discovery for ConcurrentDiscovery