pub struct NodeInfo {
pub node_id: NodeId,
pub data: NodeData,
}
Expand description
Fields§
§node_id: NodeId
The NodeId
of the node this is about.
data: NodeData
The information published about the node.
Implementations§
Source§impl NodeInfo
impl NodeInfo
Sourcepub fn from_parts(node_id: NodeId, data: NodeData) -> Self
pub fn from_parts(node_id: NodeId, data: NodeData) -> Self
Creates a new NodeInfo
from its parts.
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 info.
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 info.
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 info.
Sourcepub fn to_node_addr(&self) -> NodeAddr
pub fn to_node_addr(&self) -> NodeAddr
Converts into a NodeAddr
by cloning the needed fields.
Sourcepub fn into_node_addr(self) -> NodeAddr
pub fn into_node_addr(self) -> NodeAddr
Converts into a NodeAddr
without cloning.
Sourcepub fn from_txt_lookup(lookup: TxtLookup) -> Result<Self>
Available on non-wasm_browser
only.
pub fn from_txt_lookup(lookup: TxtLookup) -> Result<Self>
wasm_browser
only.Parses a NodeInfo
from a TXT records lookup.
Sourcepub fn from_pkarr_signed_packet(packet: &SignedPacket) -> Result<Self>
pub fn from_pkarr_signed_packet(packet: &SignedPacket) -> Result<Self>
Parses a NodeInfo
from a [pkarr::SignedPacket
].
Sourcepub fn to_pkarr_signed_packet(
&self,
secret_key: &SecretKey,
ttl: u32,
) -> Result<SignedPacket>
pub fn to_pkarr_signed_packet( &self, secret_key: &SecretKey, ttl: u32, ) -> Result<SignedPacket>
Creates a [pkarr::SignedPacket
].
This constructs a DNS packet and signs it with a SecretKey
.
Sourcepub fn to_txt_strings(&self) -> Vec<String>
pub fn to_txt_strings(&self) -> Vec<String>
Converts into a list of {key}={value}
strings.
Methods from Deref<Target = NodeData>§
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 NodeInfo
impl StructuralPartialEq for NodeInfo
Auto Trait Implementations§
impl Freeze for NodeInfo
impl RefUnwindSafe for NodeInfo
impl Send for NodeInfo
impl Sync for NodeInfo
impl Unpin for NodeInfo
impl UnwindSafe for NodeInfo
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.