pub trait Callback: Send {
// Provided methods
fn requires(&self) -> Vec<DiagnosticRequest> { ... }
fn requires_for(
&self,
_hook: CallbackHook,
_iteration: usize,
) -> Vec<DiagnosticRequest> { ... }
fn on_start(&mut self, _context: &StepContext<'_>) -> Result<CallbackAction> { ... }
fn on_frame_end(
&mut self,
_context: &StepContext<'_>,
) -> Result<CallbackAction> { ... }
fn on_iteration_end(
&mut self,
_context: &StepContext<'_>,
) -> Result<CallbackAction> { ... }
fn on_finish(&mut self, _result: &ReconstructionResult) -> Result<()> { ... }
}Expand description
Thread-sendable observer or early-stop controller for reconstruction execution.
Implementors declare diagnostics before hooks so the runner computes only requested snapshots. Hooks receive borrowed state and cannot mutate numerical reconstruction data.
Provided Methods§
Sourcefn requires(&self) -> Vec<DiagnosticRequest>
fn requires(&self) -> Vec<DiagnosticRequest>
Declares diagnostics required at every hook by legacy or non-periodic callbacks.
Sourcefn requires_for(
&self,
_hook: CallbackHook,
_iteration: usize,
) -> Vec<DiagnosticRequest>
fn requires_for( &self, _hook: CallbackHook, _iteration: usize, ) -> Vec<DiagnosticRequest>
Requests diagnostics for a specific hook. Built-in periodic callbacks override this to avoid computing snapshots on inactive iterations.
Sourcefn on_start(&mut self, _context: &StepContext<'_>) -> Result<CallbackAction>
fn on_start(&mut self, _context: &StepContext<'_>) -> Result<CallbackAction>
Runs once after state initialization and may stop before processing frames.
Sourcefn on_frame_end(&mut self, _context: &StepContext<'_>) -> Result<CallbackAction>
fn on_frame_end(&mut self, _context: &StepContext<'_>) -> Result<CallbackAction>
Runs once for every completed frame when frame callbacks are enabled.
For multi-frame algorithms, all frames in a batch observe the same
post-batch state while frame_index and natural loss remain per-frame.
Sourcefn on_iteration_end(
&mut self,
_context: &StepContext<'_>,
) -> Result<CallbackAction>
fn on_iteration_end( &mut self, _context: &StepContext<'_>, ) -> Result<CallbackAction>
Runs after a complete iteration and may request clean termination.
Sourcefn on_finish(&mut self, _result: &ReconstructionResult) -> Result<()>
fn on_finish(&mut self, _result: &ReconstructionResult) -> Result<()>
Runs once with the final owned result; errors are propagated by the runner.