2015-12-20 09:48:52 +13:00
2015-12-07 17:11:54 +13:00
2015-11-20 22:06:34 -05:00
2014-12-15 02:55:49 +13:00
2015-12-05 20:57:14 -05:00
2015-12-07 17:11:54 +13:00
2015-11-29 22:35:54 +13:00
2015-11-29 22:51:14 +13:00

Notify

Crate version Crate license Crate download count

Appveyor (Windows) Travis (Linux and OS X)

Code of Conduct

Cross-platform filesystem notification library for Rust.

Install

[dependencies]
notify = "^2.5.0"

Usage

extern crate notify;

use notify::{RecommendedWatcher, Error, Watcher};
use std::sync::mpsc::channel;

fn main() {
  // Create a channel to receive the events.
  let (tx, rx) = channel();

  // Automatically select the best implementation for your platform.
  // You can also access each implementation directly e.g. INotifyWatcher.
  let mut w: Result<RecommendedWatcher, Error> = Watcher::new(tx);

  match w {
    Ok(mut watcher) => {
      // Add a path to be watched. All files and directories at that path and
      // below will be monitored for changes.
      watcher.watch("/home/test/notify");

      // You'll probably want to do that in a loop. The type to match for is
      // notify::Event, look at src/lib.rs for details.
      match rx.recv() {
        _ => println!("Recv.")
      }
    },
    Err(e) => println!("Error")
  }
}

Platforms

  • Linux / Android: inotify
  • OS X: FSEvent
  • Windows: ReadDirectoryChangesW
  • All platforms: polling

Todo

  • BSD / OS X / iOS: kqueue
  • Solaris 11: FEN

Pull requests and bug reports happily accepted!

Origins

Inspired by Go's fsnotify, born out of need for cargo watch, and general frustration at the non-existence of C/Rust cross-platform notify libraries.

Written by Félix Saparelli and awesome contributors, and released in the Public Domain using the Creative Commons Zero Declaration.

S
Description
No description provided
Readme 1.2 MiB
Languages
Rust 99.5%
Shell 0.5%