pub struct DiskQuota { /* private fields */ }Expand description
A byte budget for the files in one VFS.
Implementations§
Source§impl DiskQuota
impl DiskQuota
pub fn new(limit: u64, used: u64) -> Self
Sourcepub fn unmeasured(limit: u64) -> Self
pub fn unmeasured(limit: u64) -> Self
A budget for a directory whose usage is unknown: every write that grows it is refused.
pub fn limit(&self) -> u64
pub fn used(&self) -> u64
Sourcepub fn set_used(&self, bytes: u64)
pub fn set_used(&self, bytes: u64)
Replace measured usage while the caller exclusively owns the volume and no outstanding reservations can change this counter.
pub fn is_unmeasured(&self) -> bool
Sourcepub fn reserve(&self, bytes: u64) -> Result<(), QuotaExceeded>
pub fn reserve(&self, bytes: u64) -> Result<(), QuotaExceeded>
Claim bytes, or refuse without claiming anything when they don’t fit.
Claiming nothing always succeeds, so a write that doesn’t grow the files
works even in a directory already over its limit.
Sourcepub fn record(&self, bytes: u64)
pub fn record(&self, bytes: u64)
Count bytes already on disk, whether or not they fit: they are there.
pub fn release(&self, bytes: u64)
Sourcepub fn hold(
self: &Arc<Self>,
file: FileIdentity,
holder: Holder,
) -> OpenFileGuard
pub fn hold( self: &Arc<Self>, file: FileIdentity, holder: Holder, ) -> OpenFileGuard
Hold file open until the returned guard drops.
Sourcepub fn is_held(&self, file: FileIdentity) -> bool
pub fn is_held(&self, file: FileIdentity) -> bool
Whether a reader or writer holds file open, so its bytes outlive its name.
Sourcepub fn release_file(&self, file: FileIdentity, bytes: u64)
pub fn release_file(&self, file: FileIdentity, bytes: u64)
A regular file’s name was removed or replaced: free its bytes now, or
when the last reader holding it closes. A writer’s own file is left for
the writer to settle.