https://github.com/nurmohammed840/nio
Nio is an experimental async runtime for Rust
https://github.com/nurmohammed840/nio
async runtime
Last synced: 3 months ago
JSON representation
Nio is an experimental async runtime for Rust
- Host: GitHub
- URL: https://github.com/nurmohammed840/nio
- Owner: nurmohammed840
- Created: 2024-11-24T14:52:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-01T08:32:00.000Z (4 months ago)
- Last Synced: 2026-01-04T05:54:48.510Z (3 months ago)
- Topics: async, runtime
- Language: Rust
- Homepage: https://nurmohammed840.github.io/posts/announcing-nio/
- Size: 758 KB
- Stars: 324
- Watchers: 4
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - nurmohammed840/nio - Nio is an experimental async runtime for Rust (<a name="Rust"></a>Rust)
README
## Nio
Nio is an experimental async runtime for Rust.
For more information, check out [this article](https://nurmohammed840.github.io/posts/announcing-nio/)
Nio focuses solely on providing an async runtime, It doesn't include additional utilities like. `io`, `sync`,
You'll still need to rely on libraries like `tokio` for everything else.
## Example
Add the following dependency to your `Cargo.toml`:
```toml
[dependencies]
nio = "0.0.2"
```
Here is a basic echo server example:
```rust, ignore
use nio::net::TcpListener;
use std::io;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[nio::main]
async fn main() -> io::Result<()> {
let listener = TcpListener::bind("127.0.0.1:8080").await?;
println!("{listener:#?}");
loop {
let (mut stream, addr) = listener.accept().await?;
println!("[INCOMING] {addr:?}");
nio::spawn(async move {
let mut buf = vec![0; 1024];
while let Ok(n) = stream.read(&mut buf).await {
if n == 0 { break }
stream.write_all(&buf[..n]).await.unwrap();
}
});
}
}
```