AddressLookup

Trait AddressLookup 

Source
pub trait AddressLookup:
    Debug
    + Send
    + Sync
    + 'static {
    // Provided methods
    fn publish(&self, _data: &EndpointData) { ... }
    fn resolve(
        &self,
        _endpoint_id: EndpointId,
    ) -> Option<BoxStream<Result<Item, Error>>> { ... }
}
Expand description

AddressLookup system 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 AddressLookup 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 Address Lookup, the super::Endpoint will call publish whenever Address Lookup information changes. If an Address Lookup 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 Address Lookup mechanism.

This is fire and forget, since the Endpoint can not wait for successful publishing. If publishing is async, the implementation should start its 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<Item, Error>>>

Resolves the Item for the given EndpointId.

Once the returned [BoxStream] is dropped, the service should stop any pending work.

Implementations on Foreign Types§

Source§

impl<T: AddressLookup> AddressLookup for Arc<T>

Source§

fn publish(&self, data: &EndpointData)

Source§

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

Implementors§