async-socket

Crates.ioasync-socket
lib.rsasync-socket
version0.1.2
sourcesrc
created_at2021-10-20 18:59:58.915572
updated_at2021-10-20 19:29:43.900515
descriptionGeneral-purpose asynchronous socket stream.
homepagehttps://github.com/xpepermint/async-socket-rs/
repositoryhttps://github.com/xpepermint/async-socket-rs
max_upload_size
id468065
size10,522
Kristijan Sedlak (xpepermint)

documentation

https://docs.rs/async-socket

README

async-socket

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.

Documentation Source

Usage

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

Commit count: 8

cargo fmt