Skip to main content

RemovalPlan

Struct RemovalPlan 

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

An in-memory plan containing items to keep or delete beneath a root directory.

Created by crate::build_plan. Constructing or querying a RemovalPlan is strictly read-only and never modifies the filesystem.

§Item Collections

A RemovalPlan separates discovered filesystem items into three collections:

  • keep_items: Contains all items directly matched by keep patterns, plus all ancestor directories required to preserve their paths from the root.
  • delete_items: Contains every individual item targeted for deletion. This comprehensive list is suitable for full previews, logging, or reporting.
  • delete_roots: Contains only the top-level deletion targets. When an entire directory is targeted for deletion, its descendants appear in delete_items but are excluded from delete_roots. This minimal set is ideal for executing deletion via recursive removal routines without redundant operations.

Implementations§

Source§

impl RemovalPlan

Source

pub fn root(&self) -> &Path

Returns the normalized root directory of the plan.

The root directory itself is never included in any keep or delete list.

Source

pub fn direct_match_count(&self) -> usize

Returns the number of items that directly matched one or more keep patterns.

Directories kept solely because they are ancestors of matched items are not included in this count.

Source

pub fn keep_items(&self) -> &[PlannedItem]

Returns all kept items and their required ancestor directories, sorted by relative path.

Source

pub fn delete_items(&self) -> &[PlannedItem]

Returns all items targeted for deletion, sorted by relative path.

This is the complete, exhaustive list of all deletion targets, including items inside directories that will be removed.

Source

pub fn delete_roots(&self) -> &[PlannedItem]

Returns the minimal top-level items targeted for deletion, sorted by relative path.

If a directory is targeted for deletion, the directory itself is included in this list, but its child items are omitted. This provides the minimal set of targets needed to execute recursive deletion safely and efficiently.

Trait Implementations§

Source§

impl Debug for RemovalPlan

Source§

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

Formats the value using the given formatter. 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 = !

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.