pub struct ControlTable { /* private fields */ }Expand description
Exact .gitignore sources and parsed matchers, keyed by governing directory.
Identical sources are stored and parsed once. A tree of package checkouts repeats a few
.gitignore files thousands of times, and charging every copy for its bytes and matcher
crossed the bound at a fraction of the distinct rules the tree holds (fdu-szkg). Each
directory still pays for its own key, so a tree of empty control files cannot evade the
bound, and removing the last holder of a content releases the content’s charge.
A source the limits cannot admit is refused, not an error: the table records the refusal and keeps no rules for that directory, and the scan that read it continues (fdu-1onj). A refusal ends when the directory’s control file is removed or a later read admits it.
Implementations§
Source§impl ControlTable
impl ControlTable
Sourcepub fn upsert(
&mut self,
path: &Path,
source: Vec<u8>,
) -> Result<ControlAdmission>
pub fn upsert( &mut self, path: &Path, source: Vec<u8>, ) -> Result<ControlAdmission>
Insert or replace one verified control source.
path names the control file relative to the index root. The source is retained
exactly, while matching state is derived once per distinct content rather than per
directory or per entry. A source the limits cannot admit is refused and recorded,
and a source it replaces is dropped with it: rules no longer on disk must not keep
applying. The line limit is checked first, so a source both limits refuse is
refused for its line.
§Errors
crate::Error::InvalidControlPath when path does not name a control file.
Sourcepub fn remove(&mut self, path: &Path) -> Result<bool>
pub fn remove(&mut self, path: &Path) -> Result<bool>
Remove one control source, or the record of its refusal. Missing sources are no-ops.
§Errors
crate::Error::InvalidControlPath when path does not name a control file.
Sourcepub fn matcher_for<'a>(&'a self, path: &'a Path) -> ControlMatcher<'a>
pub fn matcher_for<'a>(&'a self, path: &'a Path) -> ControlMatcher<'a>
Matcher view for one retained path.
Sourcepub fn is_ignored(&self, path: &Path, is_dir: bool) -> bool
pub fn is_ignored(&self, path: &Path, is_dir: bool) -> bool
Evaluate complete ignore semantics without relying on retained parent facts.
The index hot path uses ControlMatcher::is_ignored with the parent’s stored
classification. This standalone form evaluates each directory prefix so callers
and tests receive the same answer even without an index entry in hand.
Sourcepub fn affected_subtree(path: &Path) -> Result<PathBuf>
pub fn affected_subtree(path: &Path) -> Result<PathBuf>
Relative subtree whose classification may move when path changes.
Sourcepub fn refusals(&self) -> impl ExactSizeIterator<Item = RefusedControl> + '_
pub fn refusals(&self) -> impl ExactSizeIterator<Item = RefusedControl> + '_
Every refused control file and its reason, in governing-directory order.
Sourcepub fn refused_len(&self) -> usize
pub fn refused_len(&self) -> usize
Number of refused control files.
Sourcepub const fn limits(&self) -> ControlLimits
pub const fn limits(&self) -> ControlLimits
The limits this table admits sources under.
Sourcepub fn observation(&self) -> ControlObservation
pub fn observation(&self) -> ControlObservation
This table’s coverage, listing at most crate::MAX_RETAINED_ISSUES refusals.
Sourcepub const fn source_bytes(&self) -> usize
pub const fn source_bytes(&self) -> usize
Exact retained source bytes across the whole table.
Sourcepub const fn retained_cost(&self) -> usize
pub const fn retained_cost(&self) -> usize
Bounded retained charge for the complete table.