quill_sql/storage/io/
mod.rs

1use bytes::{Bytes, BytesMut};
2use std::sync::mpsc::Receiver;
3
4use crate::buffer::PageId;
5use crate::error::QuillSQLResult;
6
7pub type DiskCommandResultReceiver<T> = Receiver<QuillSQLResult<T>>;
8
9/// IO backend abstraction for DiskScheduler.
10/// Implementations are responsible for request routing and graceful shutdown.
11pub trait IOBackend: Send + Sync {
12    /// Schedule single-page read.
13    fn schedule_read(&self, page_id: PageId)
14        -> QuillSQLResult<DiskCommandResultReceiver<BytesMut>>;
15    /// Schedule batch reads, preserving order of input page_ids in the output.
16    fn schedule_read_pages(
17        &self,
18        page_ids: Vec<PageId>,
19    ) -> QuillSQLResult<DiskCommandResultReceiver<Vec<BytesMut>>>;
20    /// Schedule single-page write (exact PAGE_SIZE bytes).
21    fn schedule_write(
22        &self,
23        page_id: PageId,
24        data: Bytes,
25    ) -> QuillSQLResult<DiskCommandResultReceiver<()>>;
26    /// Allocate a new page id.
27    fn schedule_allocate(&self) -> QuillSQLResult<DiskCommandResultReceiver<PageId>>;
28    /// Deallocate a page id (zeroing on disk, then freelist push).
29    fn schedule_deallocate(&self, page_id: PageId)
30        -> QuillSQLResult<DiskCommandResultReceiver<()>>;
31}
32
33#[cfg_attr(not(target_os = "linux"), allow(unused))]
34pub mod thread_pool;
35
36#[cfg(target_os = "linux")]
37pub mod iouring;