automata/fsevent/event
Types
One file-system event derived from a snapshot diff.
opaque so the smart constructors can enforce two invariants the
type would otherwise leave open:
opsis never empty (an event with nothing observed makes no sense; the differ filters those out before constructing one).renamed_fromisSome(_)only whenopscontainsRename.
These rules mirror Go fsnotify’s Event and notify-rs’s
RenameMode::Both: the rename’s old path is attached to the new
path event, not to a parallel Remove.
pub opaque type WatchEvent
Values
pub fn created(path path: path.NormalizedPath) -> WatchEvent
Create-only event for path.
pub fn event_has(event event: WatchEvent, op op: ast.Op) -> Bool
pub fn event_ops(event event: WatchEvent) -> set.Set(ast.Op)
pub fn event_path(event event: WatchEvent) -> path.NormalizedPath
pub fn event_renamed_from(
event event: WatchEvent,
) -> option.Option(path.NormalizedPath)
pub fn event_to_string(event event: WatchEvent) -> String
Render an event in fsnotify-go style: "WRITE /tmp/a" for a
single-op event, "CREATE|WRITE /tmp/a" for compound ops, and
"RENAME /tmp/b <- /tmp/a" for renames. The arrow is ASCII (<-)
so the rendering is safe to use in any terminal.
pub fn multi_op(
path path: path.NormalizedPath,
ops ops: set.Set(ast.Op),
renamed_from from: option.Option(path.NormalizedPath),
) -> Result(WatchEvent, ast.FseventError)
Build an event whose op set may carry several ops at once (for
example a freshly created non-empty file is {Create, Write}).
Validates the op set is non-empty and that renamed_from only
appears together with the Rename op.
pub fn removed(path path: path.NormalizedPath) -> WatchEvent
Remove-only event for path.
pub fn renamed(
to to: path.NormalizedPath,
from from: path.NormalizedPath,
) -> WatchEvent
Rename event whose new path is to and whose old path was from.