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#![allow(unused_features)]
12#![warn(missing_docs)]
13#![deny(rustdoc::broken_intra_doc_links)]
14#![doc(
15    html_logo_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
16)]
17#![doc(
18    html_favicon_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
19)]
20
21#[cfg(feature = "arrayvec")]
22pub use arrayvec;
23#[cfg(feature = "bumpalo")]
24pub use bumpalo;
25#[cfg(feature = "bytes")]
26pub use bytes;
27#[cfg(feature = "memmap2")]
28pub use memmap2;
29
30mod io;
31pub use io::*;
32
33mod io_buf;
34pub use io_buf::*;
35
36mod io_vec_buf;
37pub use io_vec_buf::*;
38
39mod buf_result;
40pub use buf_result::*;
41
42mod slice;
43pub use slice::*;
44
45mod uninit;
46pub use uninit::*;
47
48/// Trait to get the inner buffer of an operation or a result.
49pub trait IntoInner {
50    /// The inner type.
51    type Inner;
52
53    /// Get the inner buffer.
54    fn into_inner(self) -> Self::Inner;
55}
56
57#[cfg(not(feature = "allocator_api"))]
58#[macro_export]
59#[doc(hidden)]
60macro_rules! t_alloc {
61    ($b:tt, $t:ty, $a:ident) => {
62        $b<$t>
63    };
64}
65
66#[cfg(feature = "allocator_api")]
67#[macro_export]
68#[doc(hidden)]
69macro_rules! t_alloc {
70    ($b:tt, $t:ty, $a:ident) => {
71        $b<$t, $a>
72    };
73}