pub trait FileWriteGuard: Send + Sync {
// Required method
fn name(&self) -> &str;
// Provided methods
fn enabled(&self) -> bool { ... }
fn checks_writes(&self) -> bool { ... }
fn checks_shell(&self) -> bool { ... }
fn timeout(&self) -> Option<Duration> { ... }
fn before_write(
&self,
_path: &Path,
_content: &str,
_cwd: &Path,
_lane: &str,
) -> Result<Verdict, String> { ... }
fn before_shell(
&self,
_command: &str,
_cwd: &Path,
) -> Result<Verdict, String> { ... }
fn watches_cells(&self) -> bool { ... }
fn after_cell_changes(
&self,
_changes: &CellChanges,
_cwd: &Path,
_lane: &str,
) -> Result<Option<AfterCellReport>, String> { ... }
fn after_timeout(&self) -> Duration { ... }
}Expand description
One registered guard (Loki). Err means the guard could not check (the write proceeds unchecked).
Required Methods§
Provided Methods§
Sourcefn enabled(&self) -> bool
fn enabled(&self) -> bool
False while the guard has nothing to do (checked per call; file-hooks.ts enabled).
Sourcefn checks_writes(&self) -> bool
fn checks_writes(&self) -> bool
Whether the guard checks proposed writes / shell commands at all (TS: whether beforeWrite / beforeShell
is defined); only those calls are counted in its statistics.
fn checks_shell(&self) -> bool
Sourcefn timeout(&self) -> Option<Duration>
fn timeout(&self) -> Option<Duration>
Per-call time limit of before_write and before_shell (default 5 s); None waits for the answer. A guard
that does not answer in time lets the write (or command) proceed with a note.
Sourcefn before_write(
&self,
_path: &Path,
_content: &str,
_cwd: &Path,
_lane: &str,
) -> Result<Verdict, String>
fn before_write( &self, _path: &Path, _content: &str, _cwd: &Path, _lane: &str, ) -> Result<Verdict, String>
A proposed write of the cell on lane: the absolute, normalized path and the complete new text; cwd is the
lane’s directory.
Sourcefn before_shell(&self, _command: &str, _cwd: &Path) -> Result<Verdict, String>
fn before_shell(&self, _command: &str, _cwd: &Path) -> Result<Verdict, String>
A shell command that may write files (may_write_files), before it runs in cwd.
Sourcefn watches_cells(&self) -> bool
fn watches_cells(&self) -> bool
Whether the guard wants the files each cell changed (snapshots are taken only while one does); checked per cell.
Sourcefn after_cell_changes(
&self,
_changes: &CellChanges,
_cwd: &Path,
_lane: &str,
) -> Result<Option<AfterCellReport>, String>
fn after_cell_changes( &self, _changes: &CellChanges, _cwd: &Path, _lane: &str, ) -> Result<Option<AfterCellReport>, String>
The files a cell on lane (working in cwd) changed by other means than checked writes.
Sourcefn after_timeout(&self) -> Duration
fn after_timeout(&self) -> Duration
How long after_cell_changes may take (default 120 s).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".