Skip to main content

FileHooks

Struct FileHooks 

Source
pub struct FileHooks { /* private fields */ }
Expand description

The guards of one working directory (the session’s, or a worktree subagent’s), answering the host’s files.before_write and shell checks, and checking what each cell changed (FileHooks).

Implementations§

Source§

impl FileHooks

Source

pub fn new(cwd: impl Into<PathBuf>) -> Self

Source

pub fn with_snapshots(cwd: impl Into<PathBuf>, snapshot: Snapshotter) -> Self

Hooks that also check what each cell changed, picturing the directory with snapshot.

Source

pub fn add(&mut self, guard: Box<dyn FileWriteGuard>)

Source

pub fn protect(&self, paths: Vec<PathBuf>, home: &Path)

No cell writes paths (files, or directories with everything in them) through write()/edit() or a shell command that names one: they are the user’s to change (the profile’s settings, keys and skills). home is the home directory a command may name them from.

Source

pub fn observe(&self, observer: Arc<dyn CellObserver>)

observer sees what each cell changed (after the guards); its lines go with the lane’s next cell result.

Source

pub fn ignore_outside(&self, changes: OutsideChanges)

Files changes records as changed outside the cells are not a cell’s changes (unless it changed them again), and an after-cell check waits for that work to end first.

Source

pub fn on_record(&self, on_record: OnRecord)

Every guard outcome goes to on_record (ULTRON_LOKI_LOG).

Source

pub fn set_clock(&self, now: Clock)

The clock guard times are measured with (tests).

Source

pub fn begin_turn(&self)

A new root turn began: per-turn times start from zero.

Source

pub fn stats(&self) -> Vec<GuardStats>

Each guard’s statistics, in registration order.

Source

pub fn watches_cells(&self) -> bool

True when some guard wants to see changes after each cell (snapshots are taken only then).

Source

pub fn cell_started(&self, lane: &str)

A cell is starting on lane: the directory as it is now is what its end is compared with. While no other lane’s cell runs that is the latest picture (taken after the previous cell); otherwise a picture is taken now, so the other lane’s changes made before this start are not this lane’s.

Source

pub fn cell_ended(&self, lane: &str)

A cell on lane ended: in the background, diff the directory against the lane’s picture from the cell’s start and give the guards the files changed by other means than checked writes. Returns at once; Self::settled waits.

Source

pub fn settled(&self)

Wait for the after-cell checks already started.

Source

pub fn take_pending(&self, lane: &str) -> Option<String>

Findings from after-cell checks not yet shown to lane, as one block of text (and forget them).

Trait Implementations§

Source§

impl Clone for FileHooks

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Guard for FileHooks

Source§

fn before_shell(&self, lane: &str, command: &str) -> Option<String>

beforeShell of a command on lane: commands that may write no file, or with no shell guard, are allowed at once. Some(reasons) blocks it. Notes (a guard that could not check, advise-only refusals) are not shown for shell commands.

Source§

fn before_write(&self, lane: &str, path: &str, content: &str) -> Value

beforeWrite of one proposed write on lane: every enabled guard, in parallel, each within its time limit.

Source§

fn guard_stats(&self) -> Vec<Value>

Each file-hook guard’s statistics (fileHooks.stats()), for rlm.pool.
Source§

fn begin_turn(&self)

A new root turn began: per-turn guard times start from zero.
Source§

fn cell_started(&self, lane: &str)

A cell on lane is starting (after-cell checks take their baseline).
Source§

fn cell_ended(&self, lane: &str)

A cell on lane ended (after-cell checks start in the background).
Source§

fn take_pending(&self, lane: &str) -> Option<String>

What after-cell checks found for lane and it has not been shown yet.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more