pub struct NodeData { /* private fields */ }
Expand description
Data about a node that may be published to and resolved from discovery services.
This includes an optional RelayUrl
, a set of direct addresses, and the optional
UserData
, a string that can be set by applications and is not parsed or used by iroh
itself.
This struct does not include the node’s NodeId
, only the data about a certain
node. See NodeInfo
for a struct that contains a NodeId
with associated NodeData
.
Implementations§
Source§impl NodeData
impl NodeData
Sourcepub fn new(
relay_url: Option<RelayUrl>,
direct_addresses: BTreeSet<SocketAddr>,
) -> Self
pub fn new( relay_url: Option<RelayUrl>, direct_addresses: BTreeSet<SocketAddr>, ) -> Self
Creates a new NodeData
with a relay URL and a set of direct addresses.
Sourcepub fn with_relay_url(self, relay_url: Option<RelayUrl>) -> Self
pub fn with_relay_url(self, relay_url: Option<RelayUrl>) -> Self
Sets the relay URL and returns the updated node data.
Sourcepub fn with_direct_addresses(
self,
direct_addresses: BTreeSet<SocketAddr>,
) -> Self
pub fn with_direct_addresses( self, direct_addresses: BTreeSet<SocketAddr>, ) -> Self
Sets the direct addresses and returns the updated node data.
Sourcepub fn with_user_data(self, user_data: Option<UserData>) -> Self
pub fn with_user_data(self, user_data: Option<UserData>) -> Self
Sets the user-defined data and returns the updated node data.
Sourcepub fn user_data(&self) -> Option<&UserData>
pub fn user_data(&self) -> Option<&UserData>
Returns the optional user-defined data of the node.
Sourcepub fn direct_addresses(&self) -> &BTreeSet<SocketAddr>
pub fn direct_addresses(&self) -> &BTreeSet<SocketAddr>
Returns the direct addresses of the node.
Sourcepub fn clear_direct_addresses(&mut self)
pub fn clear_direct_addresses(&mut self)
Removes all direct addresses from the node data.
Sourcepub fn add_direct_addresses(
&mut self,
addrs: impl IntoIterator<Item = SocketAddr>,
)
pub fn add_direct_addresses( &mut self, addrs: impl IntoIterator<Item = SocketAddr>, )
Adds direct addresses to the node data.
Sourcepub fn set_relay_url(&mut self, relay_url: Option<RelayUrl>)
pub fn set_relay_url(&mut self, relay_url: Option<RelayUrl>)
Sets the relay URL of the node data.
Sourcepub fn set_user_data(&mut self, user_data: Option<UserData>)
pub fn set_user_data(&mut self, user_data: Option<UserData>)
Sets the user-defined data of the node data.
Trait Implementations§
impl Eq for NodeData
impl StructuralPartialEq for NodeData
Auto Trait Implementations§
impl Freeze for NodeData
impl RefUnwindSafe for NodeData
impl Send for NodeData
impl Sync for NodeData
impl Unpin for NodeData
impl UnwindSafe for NodeData
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.