Skip to main content

MAX_WATCH_ITERATIONS

Constant MAX_WATCH_ITERATIONS 

Source
pub const MAX_WATCH_ITERATIONS: usize = 1_000_000;
Expand description

Enters a blocking poll loop that invokes callback whenever file changes are detected.

The loop runs indefinitely until callback returns false, at which point the function returns.

§Arguments

  • watcher — A mutable reference to a FileWatcher.
  • callback — Called with the list of changed paths. Return true to keep watching, false to stop.

§Example

use std::path::PathBuf;
use std::time::Duration;
use ssg::watch::{FileWatcher, WatchConfig, watch_blocking};

let config = WatchConfig::new(PathBuf::from("content"), Duration::from_secs(1));
let mut watcher = FileWatcher::new(config).unwrap();

watch_blocking(&mut watcher, |changes| {
    println!("rebuilding for: {:?}", changes);
    // Return false to stop watching.
    false
});

Maximum polling iterations before watch_blocking exits.

Prevents unbounded loops per Power of Ten Rule 2.