Expand description
Hot-reload watcher for policy files.
Wraps the notify crate to provide a debounced stream of
filesystem events under a watched directory. The caller drains
events via PolicyWatcher::events and decides what to do (typically
call PolicyStore::load_policies to re-read the disk state).
§Debouncing
A single editor save can produce 3-5 raw events
(modify → close-write → chmod → …). The watcher coalesces events
that arrive within debounce of each other into a single batch.
The kind is collapsed to the dominant kind for the batch (Create
wins, then Write, then Remove, then Other).
§Errors
watch() returns an error if the underlying watcher cannot register the
store (for example, because it does not exist or is unreadable). Runtime
errors delivered by notify are available through
PolicyWatcher::take_errors; an empty events() result is normal and
does not indicate watcher failure.
Structs§
- Policy
Watcher - A debounced filesystem watcher.
- Watch
Event - A debounced filesystem event for a watched policy directory.
Enums§
- Watch
Event Kind - High-level event kind. Maps roughly to
notify::EventKindbut collapses the noisy variants (e.g.Modify::MetadatavsModify::Data) into one actionable case.
Functions§
- watch
- Watch a policy store for changes to Cedar files anywhere under
policies/and toschema.cedarschema. The returned watcher is debounced: events that arrive withindebounceof each other are coalesced into a single batch.