PeerWireProtocolMessage

Enum PeerWireProtocolMessage 

Source
pub enum PeerWireProtocolMessage<P>
where P: PeerProtocol,
{ KeepAlive, Choke, UnChoke, Interested, UnInterested, Have(HaveMessage), BitField(BitFieldMessage), Request(RequestMessage), Piece(PieceMessage), Cancel(CancelMessage), BitsExtension(BitsExtensionMessage), ProtExtension(P::ProtocolMessage), }
Expand description

Enumeration of messages for PeerWireProtocol.

Variants§

§

KeepAlive

Message to keep the connection alive.

§

Choke

Message to tell a peer we will not be responding to their requests.

Peers may wish to send *Interested and/or KeepAlive messages.

§

UnChoke

Message to tell a peer we will now be responding to their requests.

§

Interested

Message to tell a peer we are interested in downloading pieces from them.

§

UnInterested

Message to tell a peer we are not interested in downloading pieces from them.

§

Have(HaveMessage)

Message to tell a peer we have some (validated) piece.

§

BitField(BitFieldMessage)

Message to effectively send multiple HaveMessages in a single message.

This message is only valid when the connection is initiated with the peer.

§

Request(RequestMessage)

Message to request a block from a peer.

§

Piece(PieceMessage)

Message from a peer containing a block.

§

Cancel(CancelMessage)

Message to cancel a block request from a peer.

§

BitsExtension(BitsExtensionMessage)

Extension messages which are activated via the ExtensionBits as part of the handshake.

§

ProtExtension(P::ProtocolMessage)

Extension messages which are activated via the Extension Protocol.

In reality, this can be any type that implements ProtocolMessage if, for example, you are running a private swarm where you know all nodes support a given message(s).

Implementations§

Source§

impl<P> PeerWireProtocolMessage<P>
where P: PeerProtocol,

Source

pub fn bytes_needed(bytes: &[u8]) -> Result<Option<usize>>

Source

pub fn parse_bytes( bytes: Bytes, ext_protocol: &mut P, ) -> Result<PeerWireProtocolMessage<P>>

Source

pub fn write_bytes<W>(&self, writer: W, ext_protocol: &mut P) -> Result<()>
where W: Write,

Source

pub fn message_size(&self, ext_protocol: &mut P) -> usize

Trait Implementations§

Source§

impl<P> ManagedMessage for PeerWireProtocolMessage<P>
where P: PeerProtocol,

Source§

fn keep_alive() -> PeerWireProtocolMessage<P>

Retrieve a keep alive message variant.
Source§

fn is_keep_alive(&self) -> bool

Whether or not this message is a keep alive message.

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.