pub struct ScratchFile { /* private fields */ }Expand description
RAII-cleaned scratch file anchored under the ZLayer data dir’s tmp/.
Drop removes the file.
Implementations§
Source§impl ScratchFile
impl ScratchFile
Sourcepub fn from_named(inner: NamedTempFile) -> Self
pub fn from_named(inner: NamedTempFile) -> Self
Wrap an existing tempfile::NamedTempFile. Prefer
[zlayer_paths::ZLayerDirs::scratch_file] over calling this directly.
Sourcepub fn as_file_mut(&mut self) -> &mut File
pub fn as_file_mut(&mut self) -> &mut File
Mutable reference to the underlying file handle.
Sourcepub fn reopen(&self) -> Result<File>
pub fn reopen(&self) -> Result<File>
Open a fresh handle to the same on-disk file.
§Errors
Returns the underlying filesystem error if opening fails.
Sourcepub fn persist(self, dest: impl AsRef<Path>) -> Result<File, PersistError>
pub fn persist(self, dest: impl AsRef<Path>) -> Result<File, PersistError>
Persist the file to a permanent location, consuming the guard.
§Errors
Returns the underlying tempfile::PersistError if the rename fails.
Sourcepub fn into_temp_path(self) -> TempPath
pub fn into_temp_path(self) -> TempPath
Consume the guard and return the underlying TempPath (still
RAII-cleaned, but without an open file handle).
Trait Implementations§
Source§impl AsRef<Path> for ScratchFile
impl AsRef<Path> for ScratchFile
Auto Trait Implementations§
impl Freeze for ScratchFile
impl RefUnwindSafe for ScratchFile
impl Send for ScratchFile
impl Sync for ScratchFile
impl Unpin for ScratchFile
impl UnsafeUnpin for ScratchFile
impl UnwindSafe for ScratchFile
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