pub trait KeelCore {
// Required methods
fn configure(&mut self, policy_json: &Value) -> Result<(), KeelError>;
fn execute(
&mut self,
request: &Request,
effect: &mut dyn FnMut(u32) -> AttemptResult,
) -> Outcome;
fn report(&self) -> Value;
// Provided method
fn advance_clock(&mut self, _ms: u64) { ... }
}Expand description
The logical core surface. The real core implements this behind the C ABI in core-ffi.h; keel-core-stub implements it in-memory. Python/Node stubs mirror the same four operations on native values.
Required Methods§
Sourcefn configure(&mut self, policy_json: &Value) -> Result<(), KeelError>
fn configure(&mut self, policy_json: &Value) -> Result<(), KeelError>
Apply a policy document (keel.toml as JSON, per policy.schema.json). Reconfiguration replaces the previous policy atomically.
Sourcefn execute(
&mut self,
request: &Request,
effect: &mut dyn FnMut(u32) -> AttemptResult,
) -> Outcome
fn execute( &mut self, request: &Request, effect: &mut dyn FnMut(u32) -> AttemptResult, ) -> Outcome
Run one intercepted call through the target’s layer chain. effect
performs a single attempt (1-based attempt number) in the host
language. Must always return an Outcome — policy failures are
outcomes, not panics/exceptions.
Provided Methods§
Sourcefn advance_clock(&mut self, _ms: u64)
fn advance_clock(&mut self, _ms: u64)
Advance the core’s clock (milliseconds). The stub runs on a virtual clock starting at 0 and never sleeps — waits advance the clock and are recorded. The real core runs on real time and implements this as a no-op outside its test harness; conformance harnesses use it to model the passage of time (breaker cooldowns, cache TTLs).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".