pub struct FolderChanges { /* private fields */ }Expand description
The waiting side of a FolderWatch; see FolderChanges::next.
Cheap to clone and free to move to another thread, so each
Command::perform can take its own.
Implementations§
Source§impl FolderChanges
impl FolderChanges
Sourcepub fn next(&self) -> Vec<FolderChange>
pub fn next(&self) -> Vec<FolderChange>
Blocks until something changes in a watched folder, then returns everything that changed within the next tenth of a second, oldest first and each change once. A burst of thousands of changes therefore arrives as a few batches, not as thousands of answers.
While nothing changes the thread sleeps in the kernel and costs no processor time. When the
FolderWatch is dropped, a waiting next wakes and returns an empty list, and so does
every later call: an empty answer means “stop waiting”. Call it inside
Command::perform, never in update or view.
A rename inside one folder is one FolderChangeKind::Renamed. An entry moved from one
watched folder to another is FolderChangeKind::Removed in the first and
FolderChangeKind::Created in the second, as it is when only one side is watched.
Sourcepub fn next_within(&self, bound: Duration) -> Option<Vec<FolderChange>>
pub fn next_within(&self, bound: Duration) -> Option<Vec<FolderChange>>
Waits like next, but at most bound for the first change; None when
nothing changed in that time. The watch goes on: ask again.
Made for screen tests: a Harness runs the work of a
Command::perform on the spot, so a wait with no end
would hold the test for good. A running application has a thread for its watch and keeps
using next. Once a change has come, the tenth of a second that gathers its batch is
waited in full, so a batch is never cut short by the bound.
Trait Implementations§
Source§impl Clone for FolderChanges
impl Clone for FolderChanges
Auto Trait Implementations§
impl Freeze for FolderChanges
impl RefUnwindSafe for FolderChanges
impl Send for FolderChanges
impl Sync for FolderChanges
impl Unpin for FolderChanges
impl UnsafeUnpin for FolderChanges
impl UnwindSafe for FolderChanges
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more