Skip to main content

compio/
lib.rs

1//! # Compio
2//! A thread-per-core Rust runtime with IOCP/io_uring/polling.
3//! The name comes from "completion-based IO".
4//! This crate is inspired by [monoio](https://github.com/bytedance/monoio/).
5//!
6//! ## Quick start
7//!
8//! Add `compio` as dependency:
9//!
10//! ```bash
11//! cargo add compio --features macros,fs
12//! ```
13//!
14//! Then use the high level APIs provided to perform filesystem & network IO:
15//!
16//! ```rust
17//! use compio::{fs::File, io::AsyncReadAtExt};
18//!
19//! #[compio::main]
20//! async fn main() {
21//!     let file = File::open("Cargo.toml").await.unwrap();
22//!     let (read, buffer) = file
23//!         .read_to_end_at(Vec::with_capacity(1024), 0)
24//!         .await
25//!         .unwrap();
26//!     assert_eq!(read, buffer.len());
27//!     let buffer = String::from_utf8(buffer).unwrap();
28//!     println!("{}", buffer);
29//! }
30//! ```
31//!
32//! ## Observability
33//! The `console` feature instruments the runtime for [`tokio-console`], which
34//! [`console_subscriber`] then reports to.
35//!
36//! See [`runtime::console`] for the setup it takes, and for what is reported
37//! and what is not.
38//!
39//! [`tokio-console`]: https://github.com/tokio-rs/console
40//! [`console_subscriber`]: https://docs.rs/console-subscriber
41// The module is only there with the `runtime` feature, so the link is spelled
42// out rather than resolved, like the two above.
43//! [`runtime::console`]: https://docs.rs/compio-runtime/latest/compio_runtime/console/
44
45#![cfg_attr(docsrs, feature(doc_cfg))]
46#![allow(unused_features)]
47#![warn(missing_docs)]
48#![deny(rustdoc::broken_intra_doc_links)]
49#![doc(
50    html_logo_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
51)]
52#![doc(
53    html_favicon_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
54)]
55
56#[doc(no_inline)]
57pub use buf::BufResult;
58#[cfg(feature = "arrayvec")]
59pub use buf::arrayvec;
60#[cfg(feature = "bumpalo")]
61pub use buf::bumpalo;
62#[cfg(feature = "bytes")]
63pub use buf::bytes;
64#[cfg(feature = "smallvec")]
65pub use buf::smallvec;
66#[cfg(feature = "actor")]
67#[doc(inline)]
68pub use compio_actor as actor;
69#[cfg(feature = "compat")]
70pub use compio_compat as compat;
71#[cfg(feature = "dispatcher")]
72#[doc(inline)]
73pub use compio_dispatcher as dispatcher;
74#[cfg(feature = "fs")]
75#[doc(inline)]
76pub use compio_fs as fs;
77#[cfg(feature = "io")]
78#[doc(inline)]
79pub use compio_io as io;
80#[cfg(feature = "macros")]
81pub use compio_macros::*;
82#[cfg(feature = "net")]
83#[doc(inline)]
84pub use compio_net as net;
85#[cfg(feature = "process")]
86#[doc(inline)]
87pub use compio_process as process;
88#[cfg(feature = "quic")]
89#[doc(inline)]
90pub use compio_quic as quic;
91#[cfg(feature = "runtime")]
92#[doc(inline)]
93pub use compio_runtime as runtime;
94#[cfg(feature = "signal")]
95#[doc(inline)]
96pub use compio_signal as signal;
97#[cfg(feature = "term")]
98#[doc(inline)]
99pub use compio_term as term;
100#[cfg(feature = "tls")]
101#[doc(inline)]
102pub use compio_tls as tls;
103#[cfg(feature = "ws")]
104#[doc(inline)]
105pub use compio_ws as ws;
106#[cfg(feature = "time")]
107#[doc(inline)]
108pub use runtime::time;
109#[cfg(feature = "native-tls")]
110pub use tls::native_tls;
111#[cfg(feature = "rustls")]
112pub use tls::rustls;
113#[doc(inline)]
114pub use {compio_buf as buf, compio_driver as driver};