pub struct NodeAddr {
pub node_id: NodeId,
pub info: AddrInfo,
}
key
only.Expand description
Network-level addressing information for an iroh-net node.
This combines a node’s identifier with network-level addressing information of how to contact the node.
To establish a network connection to a node both the NodeId
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
NodeId
. -
A
RelayUrl
of the node’s home relay, this allows establishing the connection via the Relay server and is very reliable. -
One or more direct addresses on which the node might be reachable. Depending on the network location of both nodes it might not be possible to establish a direct connection without the help of a Relay server.
This structure will always contain the required NodeId
and will contain an optional
number of network-level addressing information. It is a generic addressing type used
whenever a connection to other nodes needs to be established.
Fields§
§node_id: NodeId
The node’s identifier.
info: AddrInfo
Addressing information to connect to Self::node_id
.
Implementations§
Source§impl NodeAddr
impl NodeAddr
Sourcepub fn with_relay_url(self, relay_url: RelayUrl) -> Self
pub fn with_relay_url(self, relay_url: RelayUrl) -> Self
Adds a relay url to the node’s AddrInfo
.
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 to the peer’s AddrInfo
.
Sourcepub fn from_parts(
node_id: PublicKey,
relay_url: Option<RelayUrl>,
direct_addresses: impl IntoIterator<Item = SocketAddr>,
) -> Self
pub fn from_parts( node_id: PublicKey, relay_url: Option<RelayUrl>, direct_addresses: impl IntoIterator<Item = SocketAddr>, ) -> Self
Creates a new NodeAddr
from its parts.
Sourcepub fn apply_options(&mut self, opts: AddrInfoOptions)
pub fn apply_options(&mut self, opts: AddrInfoOptions)
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<'de> Deserialize<'de> for NodeAddr
impl<'de> Deserialize<'de> for NodeAddr
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<NodeAddr> for NodeTicket
Available on crate feature base32
only.
impl From<NodeAddr> for NodeTicket
base32
only.Source§impl From<NodeTicket> for NodeAddr
Available on crate feature base32
only.
impl From<NodeTicket> for NodeAddr
base32
only.Source§fn from(ticket: NodeTicket) -> Self
fn from(ticket: NodeTicket) -> Self
Returns the addressing info from given ticket.
Source§impl Ord for NodeAddr
impl Ord for NodeAddr
Source§impl PartialOrd for NodeAddr
impl PartialOrd for NodeAddr
impl Eq for NodeAddr
impl StructuralPartialEq for NodeAddr
Auto Trait Implementations§
impl Freeze for NodeAddr
impl RefUnwindSafe for NodeAddr
impl Send for NodeAddr
impl Sync for NodeAddr
impl Unpin for NodeAddr
impl UnwindSafe for NodeAddr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)