pub struct RefCountedTempFile {
_parent_temp_dir: Arc<TempDir>,
tempfile: NamedTempFile,
current_file_disk_usage: u64,
disk_manager: Arc<DiskManager>,
}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.
Fields§
§_parent_temp_dir: Arc<TempDir>The reference to the directory in which temporary files are created to ensure it is not cleaned up prior to the NamedTempFile
tempfile: NamedTempFile§current_file_disk_usage: u64Tracks the current disk usage of this temporary file. See
Self::update_disk_usage for more details.
disk_manager: Arc<DiskManager>The disk manager that created and manages this temporary file
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 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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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