[][src]Struct enr::EnrRaw

pub struct EnrRaw<K: EnrKey> { /* fields omitted */ }

The ENR Record.

This struct will always have a valid signature, known public key type, sequence number and NodeId. All other parameters are variable/optional.

Methods

impl<K: EnrKey> EnrRaw<K>[src]

pub fn node_id(&self) -> &NodeId[src]

The NodeId for the record.

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 ip(&self) -> Option<Ipv4Addr>[src]

Returns the IPv4 address of the ENR record if it is defined.

pub fn ip6(&self) -> Option<Ipv6Addr>[src]

Returns the IPv6 address of the ENR record if it is defined.

pub fn id(&self) -> Option<String>[src]

The id of ENR record if it is defined.

pub fn tcp(&self) -> Option<u16>[src]

The TCP port of ENR record if it is defined.

pub fn tcp6(&self) -> Option<u16>[src]

The IPv6-specific TCP port of ENR record if it is defined.

pub fn udp(&self) -> Option<u16>[src]

The UDP port of ENR record if it is defined.

pub fn udp6(&self) -> Option<u16>[src]

The IPv6-specific UDP port of ENR record if it is defined.

pub fn udp_socket(&self) -> Option<SocketAddr>[src]

Provides a socket (based on the UDP port), if the IP and UDP fields are specified.

pub fn tcp_socket(&self) -> Option<SocketAddr>[src]

Provides a socket (based on the TCP port), if the IP and UDP fields are specified.

pub fn signature(&self) -> &[u8][src]

The signature of the ENR record.

pub fn public_key(&self) -> K::PublicKey[src]

Returns the public key of the ENR record.

pub fn verify(&self) -> bool[src]

Verify the signature of the ENR record.

pub fn encode(&self) -> Vec<u8>[src]

RLP encodes the ENR into a byte array.

pub fn to_base64(&self) -> String[src]

Provides the URL-safe base64 encoded "text" version of the ENR prefixed by "enr:".

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]

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]

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]

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]

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]

Sets a new public key for the record.

Trait Implementations

impl<K: Clone + EnrKey> Clone for EnrRaw<K>[src]

impl<K: EnrKey> Decodable for EnrRaw<K>[src]

impl<K: EnrKey> Encodable for EnrRaw<K>[src]

impl<K: Eq + EnrKey> Eq for EnrRaw<K>[src]

impl<K: EnrKey> FromStr for EnrRaw<K>[src]

Convert a URL-SAFE base64 encoded ENR into an ENR.

type Err = String

The associated error which can be returned from parsing.

impl<K: PartialEq + EnrKey> PartialEq<EnrRaw<K>> for EnrRaw<K>[src]

impl<K: EnrKey> StructuralEq for EnrRaw<K>[src]

impl<K: EnrKey> StructuralPartialEq for EnrRaw<K>[src]

Auto Trait Implementations

impl<K> RefUnwindSafe for EnrRaw<K> where
    K: RefUnwindSafe

impl<K> Send for EnrRaw<K> where
    K: Send

impl<K> Sync for EnrRaw<K> where
    K: Sync

impl<K> Unpin for EnrRaw<K> where
    K: Unpin

impl<K> UnwindSafe for EnrRaw<K> where
    K: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,