Skip to main content

RunHooks

Struct RunHooks 

Source
pub struct RunHooks<'a> {
    pub now: &'a mut dyn FnMut() -> Result<TimeMs, AxError>,
    pub monotonic_us: &'a mut dyn FnMut() -> u64,
    pub interrupt: &'a mut dyn FnMut(SafePoint) -> Interrupt,
    pub checkpoint: Option<&'a mut dyn FnMut(TimeMs) -> Result<Payload, AxError>>,
    pub writes: &'a dyn Fn(&ToolCall) -> Writes,
    pub invoke: &'a mut dyn ConcurrentInvoke,
    pub wait: &'a mut dyn FnMut(TimeMs) -> NextCall,
    pub deltas: Option<&'a mut (dyn FnMut(&Increment) + 'a)>,
}
Expand description

The things the driver cannot decide for itself. Closures rather than traits: no second implementation exists yet, and this library introduces a trait at a seam that already has one.

Fields§

§now: &'a mut dyn FnMut() -> Result<TimeMs, AxError>

The clock, called by the driver on its own thread and nowhere else: once per dispatch line, once per turn, once when each model attempt is sent and once when its reply is whole, once when each tool call starts and once when it answers, and once per freeze that is not a cancellation.

§monotonic_us: &'a mut dyn FnMut() -> u64

Microseconds on a clock that only moves forward, from an origin of the caller’s choosing, read beside now each time a model attempt goes out, its first content arrives and its reply is whole, and each time a tool call starts and answers. Their differences are the durations model_returned and tool_result record (kernel D20); the absolute value is never recorded.

§interrupt: &'a mut dyn FnMut(SafePoint) -> Interrupt

Answers what arrived at a safe point.

§checkpoint: Option<&'a mut dyn FnMut(TimeMs) -> Result<Payload, AxError>>

The pre-wave checkpoint. None runs without a net, which the tool layer refuses for anything that can delete.

§writes: &'a dyn Fn(&ToolCall) -> Writes

What a call may write, by its declared effect, asked before the wave runs: a wave whose every call answers Nothing changes no file, so it needs no checkpoint of its own (§8-45).

§invoke: &'a mut dyn ConcurrentInvoke

Runs a wave’s tool calls in three stages (see crate::ConcurrentInvoke). admit receives the turn’s stamp; a call’s own moments are read by the turn from now, never by the tool face, which holds no clock of its own.

§wait: &'a mut dyn FnMut(TimeMs) -> NextCall

Holds the run until the moment the watchdog set for the next call to a provider that failed, and answers whether that call may go.

Halted comes back as soon as a halt reaches the run, without waiting the rest out: a backoff grows to a minute, and a brake that engages a minute late is not one. A counted clock answers Allowed at once, because nothing it replays waits in real time.

§deltas: Option<&'a mut (dyn FnMut(&Increment) + 'a)>

Where text goes while the model is still saying it.

None runs the model without asking for a stream, which is what citysim and every offline replay do: an increment changes nothing a run decides, so a driver with nowhere to put one asks for none and the call is byte-identical to what it always was.

It takes no result, because nothing here may fail a call. What arrives is a thing to look at; the record of what was said is written from model_returned, once, afterwards.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for RunHooks<'a>

§

impl<'a> !Send for RunHooks<'a>

§

impl<'a> !Sync for RunHooks<'a>

§

impl<'a> !UnwindSafe for RunHooks<'a>

§

impl<'a> Freeze for RunHooks<'a>

§

impl<'a> Unpin for RunHooks<'a>

§

impl<'a> UnsafeUnpin for RunHooks<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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