pub struct EntryCount(/* private fields */);Expand description
Proof that one entry was counted against max_file_count while its bytes
are not yet charged.
A hardlink’s size is only known in the second extraction pass, but the
number of entries must be bounded in the first, before anything is
buffered or copied. The first pass takes an EntryCount; the second spends
it in QuotaTracker::charge, which adds the bytes without counting the
entry again. Holding one therefore makes counting an entry twice, or never,
unrepresentable.
Deliberately not Clone/Copy/Default, and only producible by
QuotaTracker::reserve_count. Zero-sized.
§Examples
A validated hardlink carries its EntryCount:
use exarch_core::SecurityConfig;
use exarch_core::security::EntryValidator;
use exarch_core::security::ValidatedEntryType;
use exarch_core::types::DestDir;
use exarch_core::types::EntryType;
use std::path::Path;
use std::path::PathBuf;
let dest = DestDir::new(PathBuf::from("/tmp"))?;
let config = SecurityConfig::default()
.with_allow_hardlinks(true)
.validate()?;
let mut validator = EntryValidator::new(&config, &dest);
let entry = validator.validate_entry(
Path::new("link"),
&EntryType::Hardlink {
target: PathBuf::from("target.txt"),
},
0,
None,
None,
None,
)?;
if let ValidatedEntryType::Hardlink { counted, .. } = entry.entry_type() {
println!("{counted:?}");
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for EntryCount
impl RefUnwindSafe for EntryCount
impl Send for EntryCount
impl Sync for EntryCount
impl Unpin for EntryCount
impl UnsafeUnpin for EntryCount
impl UnwindSafe for EntryCount
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