Skip to main content

PrunedSet

Struct PrunedSet 

Source
pub struct PrunedSet { /* private fields */ }
Expand description

Tracks paths already claimed by a rule, so nested candidates are not walked or re-reported.

This wrapper encapsulates the RefCell<HashSet<PathBuf>> to ensure borrow/borrow_mut operations are temporary and cannot overlap.

Implementations§

Source§

impl PrunedSet

Source

pub fn new() -> Self

Creates a new empty PrunedSet.

Source

pub fn contains(&self, path: &Path) -> bool

Checks if a path is directly in the pruned set.

Source

pub fn insert(&self, path: PathBuf)

Inserts a path into the pruned set.

Source

pub fn is_already_claimed(&self, path: &Path) -> bool

Whether this path overlaps a candidate that has already been reported.

Reporting both a directory and something inside it would count the nested bytes twice in the total and race the two deletions against each other. Rules within a directory are applied in order, so the overlap can be found in either direction: a nested target may be claimed before the parent enclosing it, or after.

Candidates stream to the user as they are found, so the first claim stands and the overlapping one is dropped. That can leave an enclosing directory unreclaimed, which is the safe direction to err for a tool that deletes things.

Returns true if:

  • Any ancestor of path is in the pruned set (path is inside a claimed directory)
  • Any path in the pruned set starts with path (path is a parent of something claimed)

Trait Implementations§

Source§

impl Debug for PrunedSet

Source§

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

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

impl Default for PrunedSet

Source§

fn default() -> PrunedSet

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.