| Crates.io | async-socket |
| lib.rs | async-socket |
| version | 0.1.2 |
| created_at | 2021-10-20 18:59:58.915572+00 |
| updated_at | 2021-10-20 19:29:43.900515+00 |
| description | General-purpose asynchronous socket stream. |
| homepage | https://github.com/xpepermint/async-socket-rs/ |
| repository | https://github.com/xpepermint/async-socket-rs |
| max_upload_size | |
| id | 468065 |
| size | 10,522 |
This crate implements a general-purpose asynchronous socket.
The Socket implements AsyncRead, AsyncWrite, Stream and Clone
traits and thus mimics the functionality and the behaviour of the
TcpStream and UnixStream objects. These propertis makes it a perfect
tool for testing network activities and events.
Example:
use async_socket::Socket;
use async_std::task::spawn;
use futures::io::AsyncWriteExt;
use futures::stream::StreamExt;
async fn example() {
let mut stream = Socket::default();
let mut writer = stream.clone();
spawn(async move {
writer.write(b"Hello").await.unwrap();
});
while let Some(bytes) = stream.next().await {
// ...
}
}
License: MIT