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) { ... } 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, { ... } }
Expand description
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
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.
Provided methods
fn enable_writing(&self)
fn enable_writing(&self)
Prepares the node to send messages.
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,
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,
Writes the given message to the provided writer, using the provided intermediate buffer; returns the number of bytes written to the writer.