Skip to main content

PexErrorCode

Enum PexErrorCode 

Source
#[repr(u16)]
pub enum PexErrorCode { BadMessage = 1, UnsupportedVersion = 2, RateViolation = 3, Oversized = 4, NetworkMismatch = 5, ProtocolViolation = 6, }
Expand description

The advisory pex_error code table (SPEC §4.5). pex_error is best-effort and never requires a reply; a receiver sends it alongside discarding a bad message / muting a direction.

Variants§

§

BadMessage = 1

1 — the message was not valid PEX JSON, or violated a structural MUST (e.g. a peer_id appearing in both added and dropped).

§

UnsupportedVersion = 2

2 — the handshake version is not supported by the receiver.

§

RateViolation = 3

3 — data messages arrived faster than the enforced minimum interval (SPEC §6.4).

§

Oversized = 4

4 — a frame exceeded PEX_MAX_FRAME, or a list exceeded its cap (SPEC §7).

§

NetworkMismatch = 5

5 — the handshake network_id differs from the receiver’s.

§

ProtocolViolation = 6

6 — a state-machine violation (SPEC §5.3): data before handshake, a second snapshot, or a delta before the snapshot.

Implementations§

Source§

impl PexErrorCode

Source

pub fn as_u16(self) -> u16

The numeric code as it appears on the wire.

Source

pub fn message(self) -> &'static str

A short, stable human-readable message for the pex_error.message field.

Source

pub fn is_strike(self) -> bool

Whether this code represents peer misbehavior that counts a strike toward muting (SPEC §11.2): bad-message (1), rate (3), oversize (4), and protocol (6). Version (2) and network (5) mismatch mute the direction immediately but are NOT misbehavior — the peer is simply on a different version/network, and the underlying connection MUST NOT be torn down for that reason alone (SPEC §5.2).

Trait Implementations§

Source§

impl Clone for PexErrorCode

Source§

fn clone(&self) -> PexErrorCode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PexErrorCode

Source§

impl Debug for PexErrorCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for PexErrorCode

Source§

impl Hash for PexErrorCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PexErrorCode

Source§

fn eq(&self, other: &PexErrorCode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PexErrorCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V