Skip to main content

compio_driver/buffer_pool/
mod.rs

1cfg_if::cfg_if! {
2    if #[cfg(all(io_uring, fusion))] {
3        mod iour;
4        mod fallback;
5        mod fusion;
6        pub use fusion::*;
7    } else if #[cfg(io_uring)] {
8        mod iour;
9        pub use iour::*;
10    } else {
11        mod fallback;
12        pub use fallback::*;
13    }
14}
15
16/// Trait to get the selected buffer of an io operation.
17pub trait TakeBuffer {
18    /// Selected buffer type. It keeps the reference to the buffer pool and
19    /// returns the buffer back on drop.
20    type Buffer<'a>;
21
22    /// Buffer pool type.
23    type BufferPool;
24
25    /// Take the selected buffer with `buffer_pool`, io `result` and
26    /// `buffer_id`, if io operation is success.
27    fn take_buffer(
28        self,
29        buffer_pool: &Self::BufferPool,
30        result: std::io::Result<usize>,
31        buffer_id: u16,
32    ) -> std::io::Result<Self::Buffer<'_>>;
33}