pub enum P2PMessage {
Hello(HelloMessage),
Disconnect(DisconnectReason),
Ping,
Pong,
}Expand description
This represents only the reserved p2p subprotocol messages.
Variants§
Hello(HelloMessage)
The first packet sent over the connection, and sent once by both sides.
Disconnect(DisconnectReason)
Inform the peer that a disconnection is imminent; if received, a peer should disconnect immediately.
Ping
Requests an immediate reply of P2PMessage::Pong from the peer.
Pong
Reply to the peer’s P2PMessage::Ping packet.
Implementations§
Source§impl P2PMessage
impl P2PMessage
Sourcepub const fn message_id(&self) -> P2PMessageID
pub const fn message_id(&self) -> P2PMessageID
Gets the P2PMessageID for the given message.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for P2PMessage
impl<'arbitrary> Arbitrary<'arbitrary> for P2PMessage
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moreSource§impl Clone for P2PMessage
impl Clone for P2PMessage
Source§impl Debug for P2PMessage
impl Debug for P2PMessage
Source§impl Decodable for P2PMessage
impl Decodable for P2PMessage
Source§fn decode(buf: &mut &[u8]) -> Result<Self>
fn decode(buf: &mut &[u8]) -> Result<Self>
The [Decodable] implementation for P2PMessage assumes that each of the message
variants are snappy compressed, except for the P2PMessage::Hello variant since the
hello message is never compressed in the p2p subprotocol.
The [Decodable] implementation for P2PMessage::Ping and P2PMessage::Pong expects
a snappy encoded payload, see [Encodable] implementation.
Source§impl<'de> Deserialize<'de> for P2PMessage
impl<'de> Deserialize<'de> for P2PMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Encodable for P2PMessage
impl Encodable for P2PMessage
Source§fn encode(&self, out: &mut dyn BufMut)
fn encode(&self, out: &mut dyn BufMut)
The [Encodable] implementation for P2PMessage::Ping and P2PMessage::Pong encodes
the message as RLP, and prepends a snappy header to the RLP bytes for all variants except
the P2PMessage::Hello variant, because the hello message is never compressed in the
p2p subprotocol.
impl Eq for P2PMessage
Source§impl From<P2PMessage> for P2PMessageID
impl From<P2PMessage> for P2PMessageID
Source§fn from(msg: P2PMessage) -> Self
fn from(msg: P2PMessage) -> Self
Source§impl PartialEq for P2PMessage
impl PartialEq for P2PMessage
Source§impl Serialize for P2PMessage
impl Serialize for P2PMessage
impl StructuralPartialEq for P2PMessage
Auto Trait Implementations§
impl Freeze for P2PMessage
impl RefUnwindSafe for P2PMessage
impl Send for P2PMessage
impl Sync for P2PMessage
impl Unpin for P2PMessage
impl UnsafeUnpin for P2PMessage
impl UnwindSafe for P2PMessage
Blanket Implementations§
impl<A> ArbInterop for 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreimpl<T> MaybeSerde for Twhere
T: Serialize + for<'de> Deserialize<'de>,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§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> ⓘ
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: 120 bytes
Size for each variant:
Hello: 120 bytesDisconnect: 9 bytesPing: 0 bytesPong: 0 bytes