pub struct KvSpillManager { /* private fields */ }Expand description
Manages swap file creation, opening, deletion, and space limits.
Implementations§
Source§impl KvSpillManager
impl KvSpillManager
Sourcepub fn new(spill_dir: PathBuf, max_bytes: u64) -> Result<Self>
pub fn new(spill_dir: PathBuf, max_bytes: u64) -> Result<Self>
Create a new spill manager rooted at spill_dir with a byte budget.
Creates the directory if it doesn’t exist. Removes any stale files from prior runs.
Sourcepub fn create_file(&mut self) -> Result<(u64, BufWriter<File>)>
pub fn create_file(&mut self) -> Result<(u64, BufWriter<File>)>
Create a new swap file. Returns (id, buffered_writer).
Sourcepub fn open_file(&self, id: u64) -> Result<BufReader<File>>
pub fn open_file(&self, id: u64) -> Result<BufReader<File>>
Open an existing swap file for reading.
Sourcepub fn remove_file(&mut self, id: u64) -> Result<()>
pub fn remove_file(&mut self, id: u64) -> Result<()>
Remove a swap file and reclaim its disk usage.
Sourcepub fn record_usage(&mut self, id: u64)
pub fn record_usage(&mut self, id: u64)
Record bytes written to a swap file (call after flush).
Sourcepub fn has_space(&self, estimated_bytes: u64) -> bool
pub fn has_space(&self, estimated_bytes: u64) -> bool
Check if estimated_bytes can fit within the space budget.
Sourcepub fn used_bytes(&self) -> u64
pub fn used_bytes(&self) -> u64
Current disk usage in bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KvSpillManager
impl RefUnwindSafe for KvSpillManager
impl Send for KvSpillManager
impl Sync for KvSpillManager
impl Unpin for KvSpillManager
impl UnwindSafe for KvSpillManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more