fswatch

Crates.iofswatch
lib.rsfswatch
version0.1.10
sourcesrc
created_at2016-12-22 21:17:07.611276
updated_at2016-12-22 21:17:07.611276
descriptionRust wrapper for fswatch-sys
homepage
repositoryhttps://github.com/jkcclemens/fswatch-sys
max_upload_size
id7728
size54,715
Anna (anna-is-cute)

documentation

README

fswatch

Travis Codecov Crates.io Docs.rs

This is a Rust crate to integrate with the C API of libfswatch, via fswatch-sys.

extern crate fswatch;

use fswatch::{Fsw, FswSession};

fn main() {
  // Initialize the library. This must be called before anything else can be done.
  Fsw::init_library().expect("Could not start fswatch");

  // Create a new session.
  let session = FswSession::default().unwrap();
  // Add a monitoring path, unwrapping any possible error.
  session.add_path("./").unwrap();
  // Set the callback for when events are fired, unwrapping any possible error.
  session.set_callback(|events| {
    // Prettily print out the vector of events.
    println!("{:#?}", events);
  }).unwrap();
  // Start the monitor, unwrapping any possible error. This will most likely be a blocking call.
  // See the libfswatch documentation for more information.
  session.start_monitor().unwrap();
}
extern crate fswatch;

use fswatch::{Fsw, FswSessionBuilder};

fn main() {
  Fsw::init_library().expect("Could not start fswatch");

  FswSessionBuilder::new(vec!["./"])
    .build_callback(|events| println!("{:#?}", events))
    .unwrap()
    .start_monitor()
    .unwrap();
}
extern crate fswatch;

use fswatch::{Fsw, FswSession};

fn main() {
  Fsw::init_library().expect("Could not start fswatch");

  let session = FswSession::builder().add_path("./").build().unwrap();
  for event in session {
    println!("{:#?}", event);
  }
}
Commit count: 60

cargo fmt