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#[cfg(feature = "smallvec")]
30pub use smallvec;
31
32mod io;
33pub use io::*;
34
35mod io_buf;
36pub use io_buf::*;
37
38mod io_vec_buf;
39pub use io_vec_buf::*;
40
41mod buf_result;
42pub use buf_result::*;
43
44mod slice;
45pub use slice::*;
46
47mod uninit;
48pub use uninit::*;
49
50/// Trait to get the inner buffer of an operation or a result.
51pub trait IntoInner {
52    /// The inner type.
53    type Inner;
54
55    /// Get the inner buffer.
56    fn into_inner(self) -> Self::Inner;
57}
58
59#[cfg(not(feature = "allocator_api"))]
60#[macro_export]
61#[doc(hidden)]
62macro_rules! t_alloc {
63    ($b:tt, $t:ty, $a:ident) => {
64        $b<$t>
65    };
66}
67
68#[cfg(feature = "allocator_api")]
69#[macro_export]
70#[doc(hidden)]
71macro_rules! t_alloc {
72    ($b:tt, $t:ty, $a:ident) => {
73        $b<$t, $a>
74    };
75}