pub struct Watcher(/* private fields */);Expand description
An filesystem watcher
When this object is dropped the background task associated with it will stop. You may still receive some events on your provided event handler even after this, you can safely ignore them, or drop the handler.
If your provided event handler returns an error, the background task associated with this object will stop. From then on all the methods of this object will fail.
Implementations§
Source§impl Watcher
impl Watcher
Sourcepub fn add(
&self,
path: ArcPath,
interest: BitFlags<Interest>,
) -> Result<Watched>
pub fn add( &self, path: ArcPath, interest: BitFlags<Interest>, ) -> Result<Watched>
Add a new watch
Fails if the watcher task has died. Other errors will be sent as events.
The watch ends when the returned Watched is dropped. However
it cannot be guaranteed that no events will happen for a watch
after it has been dropped. You can handle this by ignoring
events with an unknown Id.
Sourcepub fn set_poll_interval(&self, t: Duration) -> Result<()>
pub fn set_poll_interval(&self, t: Duration) -> Result<()>
Set the poll interval
The poll interval determines how often to poll a batch of files. Polling is necessary to cover cases that filesystem notifications can’t handle, such as watching a path that doesn’t yet exist. Each poll interval, poll batch files will be checked in parallel.
The minimum poll interval is 100ms, an error will be returned if you try to set the value lower than that.
Sourcepub fn set_poll_batch(&self, n: usize) -> Result<()>
pub fn set_poll_batch(&self, n: usize) -> Result<()>
Set the size of a poll batch
How many files to poll each poll interval. If this is set to 0 polling is disabled.