compio_buf/
lib.rs

1//! Utilities for working with buffers.
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, doc_auto_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
13#[cfg(feature = "arrayvec")]
14pub use arrayvec;
15#[cfg(feature = "bumpalo")]
16pub use bumpalo;
17#[cfg(feature = "bytes")]
18pub use bytes;
19
20mod io_slice;
21pub use io_slice::*;
22
23mod buf_result;
24pub use buf_result::*;
25
26mod io_buf;
27pub use io_buf::*;
28
29mod io_vec_buf;
30pub use io_vec_buf::*;
31
32mod slice;
33pub use slice::*;
34
35mod iter;
36pub use iter::*;
37
38/// Trait to get the inner buffer of an operation or a result.
39pub trait IntoInner {
40    /// The inner type.
41    type Inner;
42
43    /// Get the inner buffer.
44    fn into_inner(self) -> Self::Inner;
45}
46
47#[cfg(not(feature = "allocator_api"))]
48#[macro_export]
49#[doc(hidden)]
50macro_rules! t_alloc {
51    ($b:tt, $t:ty, $a:ident) => {
52        $b<$t>
53    };
54}
55
56#[cfg(feature = "allocator_api")]
57#[macro_export]
58#[doc(hidden)]
59macro_rules! t_alloc {
60    ($b:tt, $t:ty, $a:ident) => {
61        $b<$t, $a>
62    };
63}