Coder Social home page Coder Social logo

tokio-iocp's Introduction

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.

tokio-iocp's People

Contributors

berrysoft avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.