pub struct DiskSpaceGuard { /* private fields */ }Expand description
Thread-safe disk space guard for monitoring and enforcing disk limits.
Implementations§
Source§impl DiskSpaceGuard
impl DiskSpaceGuard
Sourcepub fn new(config: DiskSpaceGuardConfig) -> Self
pub fn new(config: DiskSpaceGuardConfig) -> Self
Create a new disk space guard with the given configuration.
Sourcepub fn default_guard() -> Self
pub fn default_guard() -> Self
Create a disk space guard with default configuration.
Sourcepub fn with_min_free(min_free_mb: usize) -> Self
pub fn with_min_free(min_free_mb: usize) -> Self
Create a disk space guard with specified minimum free space.
Create an Arc-wrapped disk space guard for sharing across threads.
Sourcepub fn check(&self) -> Result<(), DiskSpaceExhausted>
pub fn check(&self) -> Result<(), DiskSpaceExhausted>
Check disk space limit (returns error if hard limit exceeded).
This should be called periodically during file writes. It’s designed to be efficient - actual disk checks only happen at the configured interval.
Sourcepub fn check_now(&self) -> Result<(), DiskSpaceExhausted>
pub fn check_now(&self) -> Result<(), DiskSpaceExhausted>
Force an immediate disk space check (bypasses interval).
Sourcepub fn check_before_write(
&self,
estimated_bytes: u64,
) -> Result<(), DiskSpaceExhausted>
pub fn check_before_write( &self, estimated_bytes: u64, ) -> Result<(), DiskSpaceExhausted>
Pre-check if there’s enough space for an estimated write.
Sourcepub fn record_write(&self, bytes: u64)
pub fn record_write(&self, bytes: u64)
Record bytes written (for estimation).
Sourcepub fn available_space_mb(&self) -> usize
pub fn available_space_mb(&self) -> usize
Get current available space in MB.
Sourcepub fn is_available() -> bool
pub fn is_available() -> bool
Check if disk space tracking is available on this platform.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics (for testing).
Trait Implementations§
Source§impl Debug for DiskSpaceGuard
impl Debug for DiskSpaceGuard
Auto Trait Implementations§
impl !Freeze for DiskSpaceGuard
impl RefUnwindSafe for DiskSpaceGuard
impl Send for DiskSpaceGuard
impl Sync for DiskSpaceGuard
impl Unpin for DiskSpaceGuard
impl UnsafeUnpin for DiskSpaceGuard
impl UnwindSafe for DiskSpaceGuard
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.