Skip to main content

Watches

Struct Watches 

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

The native watches a root holds, and the reconciler’s handle on them.

Two kinds, tracked apart because they are retired by different rules:

  • tree directories, armed one at a time when per_dir is set. A recursive inotify watch is a descriptor per directory whether or not the sync mirrors it, so a filtered sync of a checkout would still pay for node_modules and target — the cost the exclusion exists to avoid, and on a big tree the one that hits fs.inotify.max_user_watches. Arming per directory puts the reconciler in charge: it arms exactly what it indexes, in the order it indexes it, and never reaches the excluded subtrees. The arm-before-list contract holds one level down — a directory is armed before it is read — and these are disarmed as the index drops them.
  • outside directories, holding ignore sources above the root. No hint from inside the tree could ever report those, so without them a parent .gitignore edit is invisible for the life of the sync. They are armed once and never retired, since nothing in the index tracks them.

Implementations§

Source§

impl Watches

Source

pub fn add_dir(&self, dir: &Path) -> bool

Arm a tree directory, non-recursively. false only when the process is out of watch descriptors — the caller closes the root, because a mirror with an unwatched directory in it is silently stale. Every other failure (the directory vanished mid-scan, permission) returns true: there is nothing to watch, and nothing to mirror either.

Source

pub fn watch_outside(&self, dir: &Path)

Arm a directory outside the tree because it holds an ignore source. Failure is not fatal the way a tree directory’s is: the rules were already read, and the only loss is noticing a later edit — the behavior every sync had before these were watched at all.

Source

pub fn is_per_dir(&self) -> bool

Whether the tree is watched a directory at a time rather than by one recursive watch on the root.

Source

pub fn remove_dir(&self, dir: &Path)

Disarm dir and everything under it — a deleted or newly excluded subtree. inotify drops the kernel watch on deletion by itself; this is what keeps the bookkeeping (and notify’s own map) from growing across a create/delete cycle.

Source

pub fn retain_dirs(&self, keep: &dyn Fn(&Path) -> bool)

Drop every armed tree directory keep rejects. Used after a full rescan, which replaces the index wholesale and so cannot report individual removals — the one place a whole-set pass is the right shape, since every entry has to be reconsidered anyway.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.