Skip to main content

compio_buf/
lib.rs

1//! Buffer utilities for completion-based IO.
2//!
3//! Completion APIs require passing ownership of buffers to the runtime. The
4//! crate defines [`IoBuf`] and [`IoBufMut`] traits which are implemented by
5//! buffer types that respect the safety contract.
6
7#![cfg_attr(docsrs, feature(doc_cfg))]
8#![cfg_attr(feature = "allocator_api", feature(allocator_api))]
9#![cfg_attr(feature = "read_buf", feature(read_buf, core_io_borrowed_buf))]
10#![cfg_attr(feature = "try_trait_v2", feature(try_trait_v2, try_trait_v2_residual))]
11#![warn(missing_docs)]
12#![deny(rustdoc::broken_intra_doc_links)]
13#![doc(
14    html_logo_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
15)]
16#![doc(
17    html_favicon_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
18)]
19
20#[cfg(feature = "arrayvec")]
21pub use arrayvec;
22#[cfg(feature = "bumpalo")]
23pub use bumpalo;
24#[cfg(feature = "bytes")]
25pub use bytes;
26
27mod io;
28pub use io::*;
29
30mod io_buf;
31pub use io_buf::*;
32
33mod io_vec_buf;
34pub use io_vec_buf::*;
35
36mod buf_result;
37pub use buf_result::*;
38
39mod slice;
40pub use slice::*;
41
42mod uninit;
43pub use uninit::*;
44
45/// Trait to get the inner buffer of an operation or a result.
46pub trait IntoInner {
47    /// The inner type.
48    type Inner;
49
50    /// Get the inner buffer.
51    fn into_inner(self) -> Self::Inner;
52}
53
54#[cfg(not(feature = "allocator_api"))]
55#[macro_export]
56#[doc(hidden)]
57macro_rules! t_alloc {
58    ($b:tt, $t:ty, $a:ident) => {
59        $b<$t>
60    };
61}
62
63#[cfg(feature = "allocator_api")]
64#[macro_export]
65#[doc(hidden)]
66macro_rules! t_alloc {
67    ($b:tt, $t:ty, $a:ident) => {
68        $b<$t, $a>
69    };
70}