Trait pea2pea::protocols::Writing[][src]

pub trait Writing: Pea2Pea where
    Self: Clone + Send + Sync + 'static, 
{ type Message: Send; fn write_message<W: Write>(
        &self,
        target: SocketAddr,
        message: &Self::Message,
        writer: &mut W
    ) -> Result<()>; fn enable_writing(&self) { ... }
fn write_to_stream<'life0, 'life1, 'life2, 'async_trait, W: AsyncWrite + Unpin + Send>(
        &'life0 self,
        message: Self::Message,
        addr: SocketAddr,
        buffer: &'life1 mut Vec<u8>,
        writer: &'life2 mut W
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
    where
        W: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
fn send_direct_message(
        &self,
        addr: SocketAddr,
        message: Self::Message
    ) -> Result<()> { ... }
fn send_broadcast(&self, message: Self::Message)
    where
        Self::Message: Clone
, { ... } }
Expand description

Can be used to specify and enable writing, i.e. sending outbound messages. If the Handshake protocol is enabled too, it goes into force only after the handshake has been concluded.

Associated Types

The type of the outbound messages; unless their serialization is expensive and the message is broadcasted (in which case it would get serialized multiple times), serialization should be done in Writing::write_message.

Required methods

Writes the provided payload to the given intermediate writer; the payload can get prepended with a header indicating its length, be suffixed with a character indicating that it’s complete, etc.

Provided methods

Prepares the node to send messages.

Writes the given message to the given writer, using the provided intermediate buffer; returns the number of bytes written to the writer.

Sends the provided message to the specified SocketAddr.

Broadcasts the provided message to all peers.

Implementors