Trait notify::Watcher[][src]

pub trait Watcher: Sized {
    fn new_immediate<F>(event_fn: F) -> Result<Self>
    where
        F: EventFn
;
fn watch<P: AsRef<Path>>(
        &mut self,
        path: P,
        recursive_mode: RecursiveMode
    ) -> Result<()>;
fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>; fn configure(&mut self, _option: Config) -> Result<bool> { ... } }
Expand description

Type that can deliver file activity notifications

Watcher is implemented per platform using the best implementation available on that platform. In addition to such event driven implementations, a polling implementation is also provided that should work on any platform.

Required methods

fn new_immediate<F>(event_fn: F) -> Result<Self> where
    F: EventFn
[src]

Create a new watcher in immediate mode.

Events will be sent using the provided tx immediately after they occur.

fn watch<P: AsRef<Path>>(
    &mut self,
    path: P,
    recursive_mode: RecursiveMode
) -> Result<()>
[src]

Begin watching a new path.

If the path is a directory, recursive_mode will be evaluated. If recursive_mode is RecursiveMode::Recursive events will be delivered for all files in that tree. Otherwise only the directory and its immediate children will be watched.

If the path is a file, recursive_mode will be ignored and events will be delivered only for the file.

On some platforms, if the path is renamed or removed while being watched, behaviour may be unexpected. See discussions in #165 and #166. If less surprising behaviour is wanted one may non-recursively watch the parent directory as well and manage related events.

fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>[src]

Stop watching a path.

Errors

Returns an error in the case that path has not been watched or if removing the watch fails.

Provided methods

fn configure(&mut self, _option: Config) -> Result<bool>[src]

Configure the watcher at runtime.

See the Config enum for all configuration options.

Returns

  • Ok(true) on success.
  • Ok(false) if the watcher does not support or implement the option.
  • Err(notify::Error) on failure.

Implementors

impl Watcher for NullWatcher[src]

fn new_immediate<F: EventFn>(_event_fn: F) -> Result<NullWatcher>[src]

fn watch<P: AsRef<Path>>(
    &mut self,
    path: P,
    recursive_mode: RecursiveMode
) -> Result<()>
[src]

fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>[src]

impl Watcher for PollWatcher[src]

fn new_immediate<F: EventFn>(event_fn: F) -> Result<PollWatcher>[src]

fn watch<P: AsRef<Path>>(
    &mut self,
    path: P,
    recursive_mode: RecursiveMode
) -> Result<()>
[src]

fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>[src]

impl Watcher for ReadDirectoryChangesWatcher[src]

fn new_immediate<F: EventFn>(event_fn: F) -> Result<ReadDirectoryChangesWatcher>[src]

fn watch<P: AsRef<Path>>(
    &mut self,
    path: P,
    recursive_mode: RecursiveMode
) -> Result<()>
[src]

fn unwatch<P: AsRef<Path>>(&mut self, path: P) -> Result<()>[src]

fn configure(&mut self, config: Config) -> Result<bool>[src]