pub struct LokiGuard { /* private fields */ }Implementations§
Source§impl LokiGuard
impl LokiGuard
Sourcepub fn new(root: impl Into<PathBuf>, mode: LokiMode) -> Self
pub fn new(root: impl Into<PathBuf>, mode: LokiMode) -> Self
root: the repository (or working directory) Loki checks; mode is on or advise.
Sourcepub fn with_hygiene(self, level: Level) -> Self
pub fn with_hygiene(self, level: Level) -> Self
Hygiene advisories for the lines a cell added, after a post-write check that found nothing to fix.
Sourcepub fn with_timeout(self, timeout: Option<Duration>) -> Self
pub fn with_timeout(self, timeout: Option<Duration>) -> Self
The limit on each before-write and before-shell check (see loki_timeout); None: no limit.
Sourcepub fn with_post_write(self, post_write: bool) -> Self
pub fn with_post_write(self, post_write: bool) -> Self
Whether the files each cell changed are checked after it (postWrite; default on). Outside a Git
repository only before-write checks run.
Sourcepub fn with_project_python(self, python: Option<String>) -> Self
pub fn with_project_python(self, python: Option<String>) -> Self
Post-write checks ask python (the project’s interpreter, findProjectPython; loki.ts passes it to the
engine as LOKI_PYTHON) whether newly imported modules exist.
Sourcepub fn with_hook(self, hook: HookRunner) -> Self
pub fn with_hook(self, hook: HookRunner) -> Self
The same guard with another post-write engine (tests: a stand-in that answers scripted reports).
Trait Implementations§
Source§impl FileWriteGuard for LokiGuard
impl FileWriteGuard for LokiGuard
Source§fn timeout(&self) -> Option<Duration>
fn timeout(&self) -> Option<Duration>
ULTRON_LOKI_TIMEOUT_MS when set (see loki_timeout); otherwise the in-process engine has no per-call
limit (its tool runs have their own).
Source§fn 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>
afterCellChanges: hook on the files a cell changed inside the repository (at most 40).
Source§fn 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>
lane: the absolute, normalized path and the complete new text; cwd is the
lane’s directory.Source§fn watches_cells(&self) -> bool
fn watches_cells(&self) -> bool
Source§fn before_shell(&self, command: &str, cwd: &Path) -> Result<Verdict, String>
fn before_shell(&self, command: &str, cwd: &Path) -> Result<Verdict, String>
may_write_files), before it runs in cwd.Source§fn enabled(&self) -> bool
fn enabled(&self) -> bool
enabled).Source§fn checks_writes(&self) -> bool
fn checks_writes(&self) -> bool
beforeWrite / beforeShell
is defined); only those calls are counted in its statistics.fn checks_shell(&self) -> bool
Source§fn after_timeout(&self) -> Duration
fn after_timeout(&self) -> Duration
after_cell_changes may take (default 120 s).