pub struct EndpointAddr {
pub id: EndpointId,
pub addrs: BTreeSet<TransportAddr>,
}key only.Expand description
Network-level addressing information for an iroh endpoint.
This combines an endpoint’s identifier with network-level addressing information of how to contact the endpoint.
To establish a network connection to an endpoint both the EndpointId and one or more network
paths are needed. The network paths can come from various sources:
-
An Address Lookup service which can provide routing information for a given
EndpointId. -
A
RelayUrlof the endpoint’s home relay, this allows establishing the connection via the Relay server and is very reliable. -
One or more IP based addresses on which the endpoint might be reachable. Depending on the network location of both endpoints it might not be possible to establish a direct connection without the help of a Relay server.
This structure will always contain the required EndpointId and will contain an optional
number of other addressing information. It is a generic addressing type used whenever a connection
to other endpoints needs to be established.
Fields§
§id: EndpointIdThe endpoint’s identifier.
addrs: BTreeSet<TransportAddr>The endpoint’s addresses.
Implementations§
Source§impl EndpointAddr
impl EndpointAddr
Sourcepub fn new(id: PublicKey) -> Self
pub fn new(id: PublicKey) -> Self
Creates a new EndpointAddr with no network level addresses.
This still is usable with e.g. an address lookup service to establish a connection, depending on the situation.
Sourcepub fn from_parts(
id: PublicKey,
addrs: impl IntoIterator<Item = TransportAddr>,
) -> Self
pub fn from_parts( id: PublicKey, addrs: impl IntoIterator<Item = TransportAddr>, ) -> Self
Creates a new EndpointAddr from its parts.
Sourcepub fn with_relay_url(self, relay_url: RelayUrl) -> Self
pub fn with_relay_url(self, relay_url: RelayUrl) -> Self
Adds a RelayUrl address.
Sourcepub fn with_ip_addr(self, addr: SocketAddr) -> Self
pub fn with_ip_addr(self, addr: SocketAddr) -> Self
Adds an IP based address.
Sourcepub fn with_addrs(self, addrs: impl IntoIterator<Item = TransportAddr>) -> Self
pub fn with_addrs(self, addrs: impl IntoIterator<Item = TransportAddr>) -> Self
Adds a list of addresses.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if only an EndpointId is present.
Sourcepub fn ip_addrs(&self) -> impl Iterator<Item = &SocketAddr>
pub fn ip_addrs(&self) -> impl Iterator<Item = &SocketAddr>
Returns an iterator over the IP addresses of this endpoint address.
Sourcepub fn relay_urls(&self) -> impl Iterator<Item = &RelayUrl>
pub fn relay_urls(&self) -> impl Iterator<Item = &RelayUrl>
Returns an iterator over the relay URLs of this endpoint address.
In practice this is expected to be zero or one home relay for all known cases currently.
Trait Implementations§
Source§impl Clone for EndpointAddr
impl Clone for EndpointAddr
Source§fn clone(&self) -> EndpointAddr
fn clone(&self) -> EndpointAddr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EndpointAddr
impl Debug for EndpointAddr
Source§impl<'de> Deserialize<'de> for EndpointAddr
impl<'de> Deserialize<'de> for EndpointAddr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for EndpointAddr
Source§impl From<PublicKey> for EndpointAddr
impl From<PublicKey> for EndpointAddr
Source§fn from(endpoint_id: EndpointId) -> Self
fn from(endpoint_id: EndpointId) -> Self
Source§impl Hash for EndpointAddr
impl Hash for EndpointAddr
Source§impl Ord for EndpointAddr
impl Ord for EndpointAddr
Source§fn cmp(&self, other: &EndpointAddr) -> Ordering
fn cmp(&self, other: &EndpointAddr) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for EndpointAddr
impl PartialEq for EndpointAddr
Source§fn eq(&self, other: &EndpointAddr) -> bool
fn eq(&self, other: &EndpointAddr) -> bool
self and other values to be equal, and is used by ==.