metrale_scheduler/
spill.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! 2026-09-25: [`SpillIo`], the swap files a sequence is spilled to when the KV pool
4//! runs dry. The router owns the files, their ids and the usage ledger.
5//!
6//! Owner: scheduler.
7//! Invariants: none beyond the types.
8
9use std::io::{Read, Write};
10
11use anyhow::Result;
12
13pub trait SpillIo: Send + Sync {
14    /// 2026-09-25: A fresh swap file: its id and a writer the device state streams into.
15    fn create(&self) -> Result<(u64, Box<dyn Write + Send>)>;
16    /// 2026-09-25: The reader for swap file `id`.
17    fn open(&self, id: u64) -> Result<Box<dyn Read + Send>>;
18    fn remove(&self, id: u64) -> Result<()>;
19    /// 2026-09-25: Account the finished write of `id` against the swap budget.
20    fn record_usage(&self, id: u64);
21}