Struct NodeRecord
pub struct NodeRecord {
pub address: IpAddr,
pub udp_port: u16,
pub tcp_port: u16,
pub id: FixedBytes<64>,
}
Expand description
Represents a ENR in discovery.
Note: this is only an excerpt of the NodeRecord
data structure.
Fields§
§address: IpAddr
The Address of a node.
udp_port: u16
UDP discovery port.
tcp_port: u16
TCP port of the port that accepts connections.
id: FixedBytes<64>
Public key of the discovery service
Implementations§
§impl NodeRecord
impl NodeRecord
pub fn from_secret_key(addr: SocketAddr, sk: &SecretKey) -> NodeRecord
Available on crate feature secp256k1
only.
pub fn from_secret_key(addr: SocketAddr, sk: &SecretKey) -> NodeRecord
secp256k1
only.Derive the NodeRecord
from the secret key and addr.
Note: this will set both the TCP and UDP ports to the port of the addr.
pub fn convert_ipv4_mapped(&mut self) -> bool
pub fn convert_ipv4_mapped(&mut self) -> bool
Converts the address
into an Ipv4Addr
if the address
is a mapped
Ipv6Addr
.
Returns true
if the address was converted.
See also std::net::Ipv6Addr::to_ipv4_mapped
pub fn into_ipv4_mapped(self) -> NodeRecord
pub fn into_ipv4_mapped(self) -> NodeRecord
Same as Self::convert_ipv4_mapped
but consumes the type
pub const fn with_tcp_port(self, port: u16) -> NodeRecord
pub const fn with_tcp_port(self, port: u16) -> NodeRecord
Sets the tcp port
pub const fn with_udp_port(self, port: u16) -> NodeRecord
pub const fn with_udp_port(self, port: u16) -> NodeRecord
Sets the udp port
pub const fn new(addr: SocketAddr, id: FixedBytes<64>) -> NodeRecord
pub const fn new(addr: SocketAddr, id: FixedBytes<64>) -> NodeRecord
Creates a new record from a socket addr and peer id.
pub fn new_with_ports(
ip_addr: IpAddr,
tcp_port: u16,
udp_port: Option<u16>,
id: FixedBytes<64>,
) -> NodeRecord
pub fn new_with_ports( ip_addr: IpAddr, tcp_port: u16, udp_port: Option<u16>, id: FixedBytes<64>, ) -> NodeRecord
Creates a new record from an ip address and ports.
pub const fn tcp_addr(&self) -> SocketAddr
pub const fn tcp_addr(&self) -> SocketAddr
The TCP socket address of this node
pub const fn udp_addr(&self) -> SocketAddr
pub const fn udp_addr(&self) -> SocketAddr
The UDP socket address of this node
Trait Implementations§
§impl Clone for NodeRecord
impl Clone for NodeRecord
§fn clone(&self) -> NodeRecord
fn clone(&self) -> NodeRecord
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for NodeRecord
impl Debug for NodeRecord
§impl Decodable for NodeRecord
impl Decodable for NodeRecord
§fn decode(b: &mut &[u8]) -> Result<NodeRecord, Error>
fn decode(b: &mut &[u8]) -> Result<NodeRecord, Error>
buf
must be advanced past
the decoded object.§impl<'de> Deserialize<'de> for NodeRecord
impl<'de> Deserialize<'de> for NodeRecord
§fn deserialize<__D>(
deserializer: __D,
) -> Result<NodeRecord, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
deserializer: __D,
) -> Result<NodeRecord, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Display for NodeRecord
impl Display for NodeRecord
§impl Encodable for NodeRecord
impl Encodable for NodeRecord
Source§impl From<NodeRecord> for NodeEndpoint
impl From<NodeRecord> for NodeEndpoint
Source§fn from(_: NodeRecord) -> Self
fn from(_: NodeRecord) -> Self
§impl FromStr for NodeRecord
impl FromStr for NodeRecord
§impl Hash for NodeRecord
impl Hash for NodeRecord
§impl PartialEq for NodeRecord
impl PartialEq for NodeRecord
§impl Serialize for NodeRecordwhere
NodeRecord: Display,
impl Serialize for NodeRecordwhere
NodeRecord: Display,
§fn serialize<__S>(
&self,
serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl TryFrom<&Enr<SecretKey>> for NodeRecord
Available on crate feature secp256k1
only.
impl TryFrom<&Enr<SecretKey>> for NodeRecord
secp256k1
only.§fn try_from(
enr: &Enr<SecretKey>,
) -> Result<NodeRecord, <NodeRecord as TryFrom<&Enr<SecretKey>>>::Error>
fn try_from( enr: &Enr<SecretKey>, ) -> Result<NodeRecord, <NodeRecord as TryFrom<&Enr<SecretKey>>>::Error>
§impl TryFrom<Enr<SecretKey>> for NodeRecord
Available on crate feature secp256k1
only.
impl TryFrom<Enr<SecretKey>> for NodeRecord
secp256k1
only.§fn try_from(
enr: Enr<SecretKey>,
) -> Result<NodeRecord, <NodeRecord as TryFrom<Enr<SecretKey>>>::Error>
fn try_from( enr: Enr<SecretKey>, ) -> Result<NodeRecord, <NodeRecord as TryFrom<Enr<SecretKey>>>::Error>
impl Copy for NodeRecord
impl Eq for NodeRecord
impl StructuralPartialEq for NodeRecord
Auto Trait Implementations§
impl Freeze for NodeRecord
impl RefUnwindSafe for NodeRecord
impl Send for NodeRecord
impl Sync for NodeRecord
impl Unpin for NodeRecord
impl UnwindSafe for NodeRecord
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,
§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.§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
§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 86 bytes