pub struct EndpointAddr {
pub endpoint_id: EndpointId,
pub relay_url: Option<RelayUrl>,
pub direct_addresses: BTreeSet<SocketAddr>,
}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:
-
A discovery 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 direct 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 network-level addressing information. It is a generic addressing type used
whenever a connection to other endpoints needs to be established.
Fields§
§endpoint_id: EndpointIdThe endpoint’s identifier.
relay_url: Option<RelayUrl>The endpoint’s home relay url.
direct_addresses: BTreeSet<SocketAddr>Socket addresses where the peer might be reached directly.
Implementations§
Source§impl EndpointAddr
impl EndpointAddr
Sourcepub fn new(endpoint_id: PublicKey) -> Self
pub fn new(endpoint_id: PublicKey) -> Self
Creates a new EndpointAddr with no relay_url and no direct_addresses.
Sourcepub fn with_relay_url(self, relay_url: RelayUrl) -> Self
pub fn with_relay_url(self, relay_url: RelayUrl) -> Self
Adds a relay url.
Sourcepub fn with_direct_addresses(
self,
addresses: impl IntoIterator<Item = SocketAddr>,
) -> Self
pub fn with_direct_addresses( self, addresses: impl IntoIterator<Item = SocketAddr>, ) -> Self
Adds the given direct addresses.
Sourcepub fn from_parts(
endpoint_id: PublicKey,
relay_url: Option<RelayUrl>,
direct_addresses: impl IntoIterator<Item = SocketAddr>,
) -> Self
pub fn from_parts( endpoint_id: PublicKey, relay_url: Option<RelayUrl>, direct_addresses: impl IntoIterator<Item = SocketAddr>, ) -> Self
Creates a new EndpointAddr from its parts.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true, if only a EndpointId is present.
Sourcepub fn direct_addresses(&self) -> impl Iterator<Item = &SocketAddr>
pub fn direct_addresses(&self) -> impl Iterator<Item = &SocketAddr>
Returns the direct addresses of this peer.
Trait Implementations§
Source§impl Clone for EndpointAddr
impl Clone for EndpointAddr
Source§fn clone(&self) -> EndpointAddr
fn clone(&self) -> EndpointAddr
1.0.0 · 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>,
Source§impl From<(PublicKey, Option<RelayUrl>, &[SocketAddr])> for EndpointAddr
impl From<(PublicKey, Option<RelayUrl>, &[SocketAddr])> for EndpointAddr
Source§impl From<EndpointAddr> for EndpointTicket
Available on crate feature ticket only.
impl From<EndpointAddr> for EndpointTicket
ticket only.Source§fn from(addr: EndpointAddr) -> Self
fn from(addr: EndpointAddr) -> Self
Creates a ticket from given addressing info.
Source§impl From<EndpointTicket> for EndpointAddr
Available on crate feature ticket only.
impl From<EndpointTicket> for EndpointAddr
ticket only.Source§fn from(ticket: EndpointTicket) -> Self
fn from(ticket: EndpointTicket) -> Self
Returns the addressing info from given ticket.