MCPcopy Index your code
hub / github.com/compio-rs/compio

github.com/compio-rs/compio @v0.19.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.19.1 ↗ · + Follow
3,301 symbols 9,640 edges 311 files 953 documented · 29%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<a href='https://compio.rs'>
    <img height="150" src="https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-with-text.svg">
</a>

Compio

MIT licensed crates.io docs.rs Check Test Telegram Discord

A thread-per-core Rust runtime with IOCP/io_uring/polling inspired by monoio.

Quick start

Add compio as dependency:

cargo add compio --features macros,fs

Then use the high level APIs provided to perform filesystem & network IO:

use compio::{fs::File, io::AsyncReadAtExt};

#[compio::main]
async fn main() {
    let file = File::open("Cargo.toml").await.unwrap();
    let (read, buffer) = file.read_to_end_at(Vec::with_capacity(1024), 0).await.unwrap();
    assert_eq!(read, buffer.len());
    let buffer = String::from_utf8(buffer).unwrap();
    println!("{}", buffer);
}

It's also possible to use the low-level driver (the proactor, without async executor) manually. See driver example.

Why the name?

The name comes from "completion-based IO", and follows the non-existent convention that an async runtime should be named with a suffix "io".

Comparison with other runtimes

Tokio

Tokio is a great generic-purpose async runtime. However, it is poll-based, and even uses undocumented APIs on Windows. We would like some new high-level APIs to perform IOCP/io_uring.

compio isn't tokio-based. This is mainly because tokio doesn't expose APIs to control mio, and mio doesn't expose APIs to control IOCP.

Monoio

Monoio focuses on Linux and io-uring, and fallbacks to mio on other platforms.

Glommio

Glommio doesn't support Windows.

Others

There are also lots of other great async runtimes. But most of them are (at the moment when compio was created) either poll-based, use io-uring unsoundly, or aren't cross-platform. We hope compio can fill this gap.

Contributing

There are opportunities to contribute to Compio at any level. It doesn't matter if you are just getting started with Rust or are the most weathered expert, we can use your help. If you have any question about Compio, feel free to join our telegram group. Before contributing, please checkout our contributing guide.

Extension points exported contracts — how you extend this code

AncillaryData (Interface)
Trait for types that can be encoded and decoded as ancillary data payloads. This trait enables a type to be used as the [6 …
compio-io/src/ancillary/mod.rs
ToSharedFd (Interface)
Get a clone of [`SharedFd`]. [10 implementers]
compio-driver/src/fd.rs
IoVectoredBuf (Interface)
A trait for vectored buffers. # Note for implementors The iterator must be idemptotent and always yield the same slice [10 …
compio-buf/src/io_vec_buf.rs
ToSocketAddrsAsync (Interface)
(no doc) [6 implementers]
compio-net/src/resolve/mod.rs
IntoMaybeTlsStream (Interface)
Create [`MaybeTlsStream`] with capacity and buffer size limit. [4 implementers]
compio-ws/src/lib.rs
ResumeUnwind (Interface)
Trait to resume unwind from a [`JoinError`]. [1 implementers]
compio-executor/src/join_handle.rs
Sealed (Interface)
(no doc) [3 implementers]
compio-runtime/src/future/stream.rs
Adapter (Interface)
(no doc) [2 implementers]
compio-compat/src/sys/mod.rs

Core symbols most depended-on inside this repo

unwrap
called by 1232
compio-buf/src/buf_result.rs
as_fd
called by 168
compio-driver/src/sys/pal/unix/mod.rs
expect
called by 158
compio-buf/src/buf_result.rs
map
called by 144
compio-buf/src/buf_result.rs
as_raw_fd
called by 137
compio-driver/src/sys/pal/unix/mod.rs
clone
called by 122
compio-driver/src/fd.rs
as_ptr
called by 84
compio-driver/src/key.rs
build
called by 77
compio-driver/src/lib.rs

Shape

Method 2,216
Function 552
Class 417
Interface 69
Enum 47

Languages

Rust100%

Modules by API surface

compio-quic/src/connection.rs71 symbols
compio-net/src/tcp.rs69 symbols
compio-driver/src/lib.rs68 symbols
compio-net/src/udp.rs54 symbols
compio-net/src/socket/mod.rs54 symbols
compio-fs/src/metadata/mod.rs52 symbols
compio-net/src/unix.rs46 symbols
compio-runtime/src/lib.rs44 symbols
compio-buf/src/io_buf.rs44 symbols
compio-driver/src/sys/driver/poll/mod.rs42 symbols
compio-driver/src/sys/op/managed/iour.rs41 symbols
compio-driver/src/key.rs40 symbols

For agents

$ claude mcp add compio \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact