Skip to main content

FileWriteGuard

Trait FileWriteGuard 

Source
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§

Source

fn name(&self) -> &str

Shown in notes and statistics (“Loki”).

Provided Methods§

Source

fn enabled(&self) -> bool

False while the guard has nothing to do (checked per call; file-hooks.ts enabled).

Source

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.

Source

fn checks_shell(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

fn watches_cells(&self) -> bool

Whether the guard wants the files each cell changed (snapshots are taken only while one does); checked per cell.

Source

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.

Source

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".

Implementors§