pub struct ProtectedSpool { /* private fields */ }Expand description
An owner-only temporary file used to spill buffered rows, removed on drop.
The backing file is created with [create_protected_in] (mode 0600,
unpredictable name). Append rows with write_row, then
rewind to read them back. Dropping the spool removes the
file; see the module docs for the SIGKILL/power-loss caveat.
Writes go through one persistent BufWriter and reuse a single scratch
buffer for the whole spool lifetime, so spilling a large family costs no
per-row writer allocation and does not flush per row — the buffer is flushed
once on rewind (or explicitly via flush).
Implementations§
Source§impl ProtectedSpool
impl ProtectedSpool
Sourcepub fn create(temp: &TempConfig) -> Result<Self>
pub fn create(temp: &TempConfig) -> Result<Self>
Create a protected spool in temp’s directory.
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
The spool’s backing path. Callers must not print this at normal verbosity — the name can leak workflow details.
Sourcepub fn write_row(&mut self, row: &SpooledRow) -> Result<()>
pub fn write_row(&mut self, row: &SpooledRow) -> Result<()>
Append one length-prefixed record, reusing the spool’s persistent buffered writer and scratch buffer (no per-row allocation, no per-row flush).
Sourcepub fn rewind(&mut self) -> Result<SpoolReader<&mut File>>
pub fn rewind(&mut self) -> Result<SpoolReader<&mut File>>
Flush buffered writes, seek to the start, and return a reader over the spooled records.
Trait Implementations§
Source§impl Drop for ProtectedSpool
impl Drop for ProtectedSpool
Auto Trait Implementations§
impl Freeze for ProtectedSpool
impl RefUnwindSafe for ProtectedSpool
impl Send for ProtectedSpool
impl Sync for ProtectedSpool
impl Unpin for ProtectedSpool
impl UnsafeUnpin for ProtectedSpool
impl UnwindSafe for ProtectedSpool
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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