pub struct InboxWatcher { /* private fields */ }Expand description
Polling watcher for the inbox directory.
Tracks one cursor per <peer>.jsonl file. poll() is a single sweep —
callers wrap in their own loop with whatever interval makes sense (sub-
second for OS toast latency, longer for batchy use cases).
Implementations§
Source§impl InboxWatcher
impl InboxWatcher
Sourcepub fn from_dir_and_cursor(
inbox_dir: PathBuf,
cursor_path: &Path,
) -> Result<Self>
pub fn from_dir_and_cursor( inbox_dir: PathBuf, cursor_path: &Path, ) -> Result<Self>
Watcher with explicit inbox dir + cursor-from-file. Resumes from saved per-peer cursors; new peer files emit from byte 0 the first time they’re seen, so the operator never misses an event between daemon writes and notifier restart.
Sourcepub fn from_dir_head(inbox_dir: PathBuf) -> Result<Self>
pub fn from_dir_head(inbox_dir: PathBuf) -> Result<Self>
Watcher with explicit inbox dir, starting from EOF on every peer file that exists at construction time. Used by MCP — agents that want history call wire_tail. Peer files created AFTER construction emit from byte 0 (they represent new conversations starting).
Sourcepub fn from_cursor_file(cursor_path: &Path) -> Result<Self>
pub fn from_cursor_file(cursor_path: &Path) -> Result<Self>
Convenience: use the configured wire inbox dir + cursor at the given
path. Equivalent to from_dir_and_cursor(config::inbox_dir()?, cursor_path).
Sourcepub fn save_cursors(&self, cursor_path: &Path) -> Result<()>
pub fn save_cursors(&self, cursor_path: &Path) -> Result<()>
Persist cursors to disk so a restart of wire notify doesn’t re-emit
already-seen events. JSON shape: {"peer1": 1234, "peer2": 5678}.
Sourcepub fn poll(&mut self) -> Result<Vec<InboxEvent>>
pub fn poll(&mut self) -> Result<Vec<InboxEvent>>
Single poll sweep. Returns all new events across all peer inbox files
since the previous sweep. Events are re-verified against the current
trust state — verified: false events are still returned (caller
decides whether to notify), but the flag is honest.