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

pub trait Writing: Pea2Pea where
    Self: Clone + Send + Sync + 'static, 
{ fn write_message(
        &self,
        target: SocketAddr,
        payload: &[u8],
        buffer: &mut [u8]
    ) -> Result<usize>; fn enable_writing(&self) { ... }
#[must_use] fn write_to_stream<'life0, 'life1, 'life2, 'life3, 'async_trait, W: AsyncWrite + Unpin + Send>(
        &'life0 self,
        message: &'life1 [u8],
        addr: SocketAddr,
        buffer: &'life2 mut [u8],
        writer: &'life3 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,
        'life3: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }

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

Required methods

fn write_message(
    &self,
    target: SocketAddr,
    payload: &[u8],
    buffer: &mut [u8]
) -> Result<usize>
[src]

Writes the provided payload to the given intermediate buffer; the payload can get prepended with a header indicating its length, be suffixed with a character indicating that it's complete, etc. Returns the number of bytes written to the buffer.

Loading content...

Provided methods

fn enable_writing(&self)[src]

Prepares the node to send messages.

#[must_use]fn write_to_stream<'life0, 'life1, 'life2, 'life3, 'async_trait, W: AsyncWrite + Unpin + Send>(
    &'life0 self,
    message: &'life1 [u8],
    addr: SocketAddr,
    buffer: &'life2 mut [u8],
    writer: &'life3 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,
    'life3: 'async_trait,
    Self: Sync + 'async_trait, 
[src]

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

Loading content...

Implementors

Loading content...