pub struct SpillFile { /* private fields */ }Expand description
A handle to a temporary spill file
The file is automatically deleted when this handle is dropped. Files are created lazily - no disk I/O occurs until the first write.
§Example
use vibesql_executor::memory::SpillFile;
use std::path::Path;
let mut file = SpillFile::new(Path::new("/tmp/vibesql"))?;
// Write sorted run
file.write_all(&serialized_data)?;
file.flush()?;
// Read back
file.seek(SeekFrom::Start(0))?;
let data = file.read_to_vec()?;
// File is automatically deleted when `file` is droppedImplementations§
Source§impl SpillFile
impl SpillFile
Sourcepub fn new(temp_dir: &Path) -> Result<Self>
pub fn new(temp_dir: &Path) -> Result<Self>
Create a new spill file in the specified directory
The file is not actually created until the first write.
Sourcepub fn with_suffix(temp_dir: &Path, suffix: &str) -> Result<Self>
pub fn with_suffix(temp_dir: &Path, suffix: &str) -> Result<Self>
Create a spill file with a specific name suffix
Useful for debugging - creates files like “vibesql_spill_12345_0_sort_run.tmp”
Sourcepub fn bytes_written(&self) -> usize
pub fn bytes_written(&self) -> usize
Get the number of bytes written to this file
Sourcepub fn is_created(&self) -> bool
pub fn is_created(&self) -> bool
Check if the file has been created on disk
Sourcepub fn prepare_for_read(&mut self) -> Result<()>
pub fn prepare_for_read(&mut self) -> Result<()>
Prepare the file for reading
This flushes any pending writes and switches to read mode.
Sourcepub fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
Read exact number of bytes
Sourcepub fn read_to_vec(&mut self) -> Result<Vec<u8>>
pub fn read_to_vec(&mut self) -> Result<Vec<u8>>
Read entire file into a Vec
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpillFile
impl RefUnwindSafe for SpillFile
impl Send for SpillFile
impl Sync for SpillFile
impl Unpin for SpillFile
impl UnwindSafe for SpillFile
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more