Skip to content

Commit

Permalink
Add doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Aug 8, 2021
1 parent 2373fd8 commit 2ea2146
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ mod config;
mod error;

/// The set of requirements for watcher event handling functions.
///
/// # Example implementation
///
/// ```no_run
/// use notify::{Event, Result, EventHandler};
///
/// /// Prints received events
/// struct EventPrinter;
///
/// impl EventHandler for EventPrinter {
/// fn handle_event(&mut self, event: Result<Event>) {
/// if let Ok(event) = event {
/// println!("Event: {:?}", event);
/// }
/// }
/// }
/// ```
pub trait EventHandler: Send + 'static {
/// Handles an event.
fn handle_event(&mut self, event: Result<Event>);
Expand Down

0 comments on commit 2ea2146

Please sign in to comment.