Skip to main content

ControlTable

Struct ControlTable 

Source
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

Source

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.

Source

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.

Source

pub fn matcher_for<'a>(&'a self, path: &'a Path) -> ControlMatcher<'a>

Matcher view for one retained path.

Source

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.

Source

pub fn affected_subtree(path: &Path) -> Result<PathBuf>

Relative subtree whose classification may move when path changes.

Source

pub fn refusals(&self) -> impl ExactSizeIterator<Item = RefusedControl> + '_

Every refused control file and its reason, in governing-directory order.

Source

pub fn refused_len(&self) -> usize

Number of refused control files.

Source

pub const fn limits(&self) -> ControlLimits

The limits this table admits sources under.

Source

pub fn observation(&self) -> ControlObservation

This table’s coverage, listing at most crate::MAX_RETAINED_ISSUES refusals.

Source

pub const fn source_bytes(&self) -> usize

Exact retained source bytes across the whole table.

Source

pub const fn retained_cost(&self) -> usize

Bounded retained charge for the complete table.

Source

pub fn source_is(&self, path: &Path, source: &[u8]) -> bool

Whether path already retains exactly source.

Source

pub fn len(&self) -> usize

Number of retained control files.

Source

pub fn is_empty(&self) -> bool

Whether no control file is retained. A table may still record refusals.

Trait Implementations§

Source§

impl Clone for ControlTable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ControlTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ControlTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.