[−][src]Struct enr::Enr
The ENR, allowing for arbitrary signing algorithms. The default signing algorithm is
secp256k1
using the libsecp256k1
library.
This struct will always have a valid signature, known public key type, sequence number and NodeId
. All other parameters are variable/optional.
Implementations
impl<K: EnrKey> Enr<K>
[src]
#[must_use]pub fn node_id(&self) -> NodeId
[src]
The NodeId
for the record.
#[must_use]pub fn seq(&self) -> u64
[src]
The current sequence number of the ENR record.
pub fn get(&self, key: impl Into<String>) -> Option<&Vec<u8>>
[src]
Reads a custom key from the record if it exists.
pub fn iter(&self) -> impl Iterator<Item = (&String, &Vec<u8>)>
[src]
Returns an iterator over all key/value pairs in the ENR.
#[must_use]pub fn ip(&self) -> Option<Ipv4Addr>
[src]
Returns the IPv4 address of the ENR record if it is defined.
#[must_use]pub fn ip6(&self) -> Option<Ipv6Addr>
[src]
Returns the IPv6 address of the ENR record if it is defined.
#[must_use]pub fn id(&self) -> Option<String>
[src]
The id
of ENR record if it is defined.
#[must_use]pub fn tcp(&self) -> Option<u16>
[src]
The TCP port of ENR record if it is defined.
#[must_use]pub fn tcp6(&self) -> Option<u16>
[src]
The IPv6-specific TCP port of ENR record if it is defined.
#[must_use]pub fn udp(&self) -> Option<u16>
[src]
The UDP port of ENR record if it is defined.
#[must_use]pub fn udp6(&self) -> Option<u16>
[src]
The IPv6-specific UDP port of ENR record if it is defined.
#[must_use]pub fn udp_socket(&self) -> Option<SocketAddr>
[src]
Provides a socket (based on the UDP port), if the IP and UDP fields are specified.
#[must_use]pub fn tcp_socket(&self) -> Option<SocketAddr>
[src]
Provides a socket (based on the TCP port), if the IP and UDP fields are specified.
#[must_use]pub fn signature(&self) -> &[u8]
[src]
The signature of the ENR record.
#[must_use]pub fn public_key(&self) -> K::PublicKey
[src]
Returns the public key of the ENR record.
#[must_use]pub fn verify(&self) -> bool
[src]
Verify the signature of the ENR record.
#[must_use]pub fn encode(&self) -> Vec<u8>
[src]
RLP encodes the ENR into a byte array.
#[must_use]pub fn to_base64(&self) -> String
[src]
Provides the URL-safe base64 encoded "text" version of the ENR prefixed by "enr:".
#[must_use]pub fn size(&self) -> usize
[src]
Returns the current size of the ENR.
pub fn set_seq(&mut self, seq: u64, key: &K) -> Result<(), EnrError>
[src]
Allows setting the sequence number to an arbitrary value.
pub fn insert(
&mut self,
key: &str,
value: Vec<u8>,
enr_key: &K
) -> Result<Option<Vec<u8>>, EnrError>
[src]
&mut self,
key: &str,
value: Vec<u8>,
enr_key: &K
) -> Result<Option<Vec<u8>>, EnrError>
Adds or modifies a key/value to the ENR record. A EnrKey
is required to re-sign the record once
modified.
Returns the previous value in the record if it exists.
pub fn set_ip(
&mut self,
ip: IpAddr,
key: &K
) -> Result<Option<IpAddr>, EnrError>
[src]
&mut self,
ip: IpAddr,
key: &K
) -> Result<Option<IpAddr>, EnrError>
Sets the ip
field of the ENR. Returns any pre-existing IP address in the record.
pub fn set_udp(&mut self, udp: u16, key: &K) -> Result<Option<u16>, EnrError>
[src]
Sets the udp
field of the ENR. Returns any pre-existing UDP port in the record.
pub fn set_udp6(&mut self, udp: u16, key: &K) -> Result<Option<u16>, EnrError>
[src]
Sets the udp6
field of the ENR. Returns any pre-existing UDP port in the record.
pub fn set_tcp(&mut self, tcp: u16, key: &K) -> Result<Option<u16>, EnrError>
[src]
Sets the tcp
field of the ENR. Returns any pre-existing tcp port in the record.
pub fn set_tcp6(&mut self, tcp: u16, key: &K) -> Result<Option<u16>, EnrError>
[src]
Sets the tcp6
field of the ENR. Returns any pre-existing tcp6 port in the record.
pub fn set_udp_socket(
&mut self,
socket: SocketAddr,
key: &K
) -> Result<(), EnrError>
[src]
&mut self,
socket: SocketAddr,
key: &K
) -> Result<(), EnrError>
Sets the IP and UDP port in a single update with a single increment in sequence number.
pub fn set_tcp_socket(
&mut self,
socket: SocketAddr,
key: &K
) -> Result<(), EnrError>
[src]
&mut self,
socket: SocketAddr,
key: &K
) -> Result<(), EnrError>
Sets the IP and TCP port in a single update with a single increment in sequence number.
pub fn set_public_key(
&mut self,
public_key: &K::PublicKey,
key: &K
) -> Result<(), EnrError>
[src]
&mut self,
public_key: &K::PublicKey,
key: &K
) -> Result<(), EnrError>
Sets a new public key for the record.
Trait Implementations
impl<K: EnrKey> Clone for Enr<K>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<K: EnrKey> Debug for Enr<K>
[src]
impl<K: EnrKey> Decodable for Enr<K>
[src]
fn decode(rlp: &Rlp) -> Result<Self, DecoderError>
[src]
impl<'de, K: EnrKey> Deserialize<'de> for Enr<K>
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<K: EnrKey> Display for Enr<K>
[src]
impl<K: EnrKey> Encodable for Enr<K>
[src]
impl<K: Eq + EnrKey> Eq for Enr<K>
[src]
impl<'_, T: EnrKey> From<&'_ Enr<T>> for NodeId
[src]
impl<T: EnrKey> From<Enr<T>> for NodeId
[src]
impl<K: EnrKey> FromStr for Enr<K>
[src]
Convert a URL-SAFE base64 encoded ENR into an ENR.
type Err = String
The associated error which can be returned from parsing.
fn from_str(base64_string: &str) -> Result<Self, Self::Err>
[src]
impl<K: EnrKey> PartialEq<Enr<K>> for Enr<K>
[src]
impl<K: EnrKey> Serialize for Enr<K>
[src]
impl<K: EnrKey> StructuralEq for Enr<K>
[src]
Auto Trait Implementations
impl<K> RefUnwindSafe for Enr<K> where
K: RefUnwindSafe,
K: RefUnwindSafe,
impl<K> Send for Enr<K> where
K: Send,
K: Send,
impl<K> Sync for Enr<K> where
K: Sync,
K: Sync,
impl<K> Unpin for Enr<K> where
K: Unpin,
K: Unpin,
impl<K> UnwindSafe for Enr<K> where
K: UnwindSafe,
K: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,