pub trait AsyncNetstringWrite: AsyncWrite + Unpin {
// Provided method
fn write_netstring<'life0, 'life1, 'async_trait>(
&'life0 mut self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Expand description
The NetstringWriter
trait allows to write a slice of bytes as a netstring to any stream that
implements AsyncWrite
Provided Methods§
Sourcefn write_netstring<'life0, 'life1, 'async_trait>(
&'life0 mut self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write_netstring<'life0, 'life1, 'async_trait>(
&'life0 mut self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Write the slice as a netstring to the stream.
§Usage
use tokio_netstring::NetstringWriter;
let msg = "Hello, World!";
stream.write_netstring(&msg.as_bytes());
§Errors
This method returns a tokio::io::Result
which is a re-export from std::io::Result
. It
returns ErrorKind::WriteZero
if the stream was closed an no more data can be sent.