pub struct RefCountedTempFile { /* private fields */ }Expand description
A wrapper around a NamedTempFile that also contains
a reference to its parent temporary directory.
§Note
After any modification to the underlying file (e.g., writing data to it), the caller
must invoke Self::update_disk_usage to update the global disk usage counter.
This ensures the disk manager can properly enforce usage limits configured by
DiskManager::with_max_temp_directory_size.
This type is Clone-able, allowing multiple references to the same underlying file. The file is deleted only when the last reference is dropped.
The parent temporary directory is also kept alive as long as any reference to this file exists, preventing premature cleanup of the directory.
Once all references to this file are dropped, the file is deleted, and the disk usage is subtracted from the disk manager’s total.
Implementations§
Source§impl RefCountedTempFile
impl RefCountedTempFile
pub fn path(&self) -> &Path
pub fn inner(&self) -> &NamedTempFile
Sourcepub fn update_disk_usage(&mut self) -> Result<()>
pub fn update_disk_usage(&mut self) -> Result<()>
Updates the global disk usage counter after modifications to the underlying file.
§Errors
- Returns an error if the global disk usage exceeds the configured limit.
pub fn current_disk_usage(&self) -> u64
Trait Implementations§
Source§impl Clone for RefCountedTempFile
impl Clone for RefCountedTempFile
Source§impl Debug for RefCountedTempFile
impl Debug for RefCountedTempFile
Auto Trait Implementations§
impl Freeze for RefCountedTempFile
impl !RefUnwindSafe for RefCountedTempFile
impl Send for RefCountedTempFile
impl Sync for RefCountedTempFile
impl Unpin for RefCountedTempFile
impl !UnwindSafe for RefCountedTempFile
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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