Skip to main content

run

Function run 

Source
pub fn run<F: FnMut() -> Result<(), RenderError>>(
    input: &Path,
    render: &mut F,
) -> Result<()>
Expand description

Run watch mode for input: register a parent-directory watch, run render once immediately, then re-run it once per settled burst of events that plausibly changed the file’s content.

render runs once immediately — before any event is seen — so callers that must do a one-time thing after the initial render (e.g. the --open browser launch) guard that in their own callback state. Its Err is ignored: a failed render must never end watch mode.

Errors propagate only from registration itself, before any render: a watch we cannot deliver aborts up front rather than rendering once and failing later. Once pumping, the loop returns Ok(()) only when the watcher channel dies; it otherwise runs until killed.