compio_buf/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! Utilities for working with buffers.
//!
//! Completion APIs require passing ownership of buffers to the runtime. The
//! crate defines [`IoBuf`] and [`IoBufMut`] traits which are implemented by
//! buffer types that respect the safety contract.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(feature = "allocator_api", feature(allocator_api))]
#![cfg_attr(feature = "read_buf", feature(read_buf, core_io_borrowed_buf))]
#![cfg_attr(feature = "try_trait_v2", feature(try_trait_v2, try_trait_v2_residual))]
#![warn(missing_docs)]

#[cfg(feature = "arrayvec")]
pub use arrayvec;
#[cfg(feature = "bumpalo")]
pub use bumpalo;
#[cfg(feature = "bytes")]
pub use bytes;

mod io_slice;
pub use io_slice::*;

mod buf_result;
pub use buf_result::*;

mod io_buf;
pub use io_buf::*;

mod io_vec_buf;
pub use io_vec_buf::*;

mod slice;
pub use slice::*;

mod iter;
pub use iter::*;

/// Trait to get the inner buffer of an operation or a result.
pub trait IntoInner {
    /// The inner type.
    type Inner;

    /// Get the inner buffer.
    fn into_inner(self) -> Self::Inner;
}

#[cfg(not(feature = "allocator_api"))]
#[macro_export]
#[doc(hidden)]
macro_rules! t_alloc {
    ($b:tt, $t:ty, $a:ident) => {
        $b<$t>
    };
}

#[cfg(feature = "allocator_api")]
#[macro_export]
#[doc(hidden)]
macro_rules! t_alloc {
    ($b:tt, $t:ty, $a:ident) => {
        $b<$t, $a>
    };
}