Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xpepermint/async-socket-rs
General-purpose asynchronous socket stream.
https://github.com/xpepermint/async-socket-rs
async channel network rust socket
Last synced: about 2 months ago
JSON representation
General-purpose asynchronous socket stream.
- Host: GitHub
- URL: https://github.com/xpepermint/async-socket-rs
- Owner: xpepermint
- Created: 2021-10-20T18:53:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-20T23:31:43.000Z (about 2 years ago)
- Last Synced: 2024-08-09T21:10:35.808Z (6 months ago)
- Topics: async, channel, network, rust, socket
- Language: Rust
- Homepage:
- Size: 28.3 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
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](https://img.shields.io/badge/-Documentation-blue?style=for-the-badge&logo=Rust)](https://docs.rs/async-socket)
[![Source](https://img.shields.io/badge/-Source-lightgrey?style=for-the-badge&logo=GitHub)](https://github.com/xpepermint/async-socket-rs)#### Usage
**Example:**
```rust
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 {
// ...
}
}
```[AsyncRead]: https://docs.rs/futures/latest/futures/prelude/trait.AsyncRead.html
[AsyncWrite]: https://docs.rs/futures/latest/futures/prelude/trait.AsyncWrite.html
[Stream]: https://docs.rs/futures/latest/futures/prelude/trait.Stream.html
[Clone]: https://doc.rust-lang.org/std/clone/trait.Clone.html
[TcpStream]: https://docs.rs/async-std/latest/async_std/net/struct.TcpStream.html
[UnixStream]: https://docs.rs/async-std/latest/async_std/os/unix/net/struct.UnixStream.htmlLicense: MIT