DirtyTracker

Struct DirtyTracker 

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

The tracker object.

This object keeps track of the dirty files in a directory.

The tracker is created with a path to a directory. It will watch for file system events in that directory and keep track of the files that have been modified.

The tracker can be in one of three states:

  • Clean: No files have been modified.
  • Dirty: Some files have been modified.
  • Unknown: The tracker is in an unknown state. This can happen if the tracker has missed some events, or if the underlying file system is behaving in an unexpected way.

Implementations§

Source§

impl DirtyTracker

Source

pub fn new(path: &Path) -> Result<Self>

Create a new tracker object.

§Arguments
  • path - The path to the directory to watch.
§Returns

A new DirtyTracker object.

Source

pub fn mark_clean(&mut self)

Mark all files as clean.

Note that this can race with file modifications, so it’s only safe if you’re sure that no modifications are happening.

Source

pub fn is_dirty(&mut self) -> bool

👎Deprecated since 0.2.0: Use state() instead

Returns true if there are dirty files.

Source

pub fn state(&mut self) -> State

Returns the state of the tracker.

Source

pub fn paths(&mut self) -> Option<&HashSet<PathBuf>>

Returns the paths of the dirty files.

If the tracker is in an unknown state, this will return None.

Source

pub fn relpaths(&mut self) -> Option<HashSet<&Path>>

Returns the relative paths of the dirty files.

If the tracker is in an unknown state, this will return None.

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.