tokio-iocp

Crates.iotokio-iocp
lib.rstokio-iocp
version0.2.3
sourcesrc
created_at2022-09-08 16:27:23.87888
updated_at2023-08-24 08:55:39.4981
descriptionIOCP support for the Tokio asynchronous runtime.
homepage
repositoryhttps://github.com/Berrysoft/tokio-iocp
max_upload_size
id661160
size180,725
王宇逸 (Berrysoft)

documentation

README

tokio-iocp

crates.io docs.rs

This crate, inspired by tokio-uring, provides IOCP for Tokio by exposing a new Runtime that is compatible with Tokio but also can drive IOCP-backed resources. Any library that works with Tokio also works with tokio-iocp. The crate provides new resource types that work with IOCP.

Getting started

Using tokio-iocp requires starting a tokio-iocp runtime. This runtime internally manages the main (single-threaded) Tokio runtime and a IOCP driver.

use tokio_iocp::fs::File;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    tokio_iocp::start(async {
        // Open a file
        let file = File::open("hello.txt")?;

        let buf = Vec::with_capacity(4096);
        // Read some data, the buffer is passed by ownership and
        // submitted to the kernel. When the operation completes,
        // we get the buffer back.
        let (res, buf) = file.read_at(buf, 0).await;
        let n = res?;

        // Display the contents
        println!("{:?}", &buf);

        Ok(())
    })
}

Requirements

Windows.

Project status

The tokio-iocp project is still very young. Currently, we are focusing on supporting filesystem and network operations. We are looking forward to your contributions!

License

This project is licensed under the MIT license.

Commit count: 120

cargo fmt