Interceptor

Trait Interceptor 

Source
pub trait Interceptor: Send + Sync {
    // Required method
    fn intercept(&self, name: &str, args: &[Value]) -> Option<Value>;
}
Expand description

Something that answers a call instead of the definition it names.

This exists for exactly one caller, and the reason it is on the seam rather than inside a backend is docs/21-tests-in-beck-and-proof.md §21.3: “A mock is not a stand-in for an object. It is a value for an effect.” A stub is therefore not a program transformation the compiler can do once — the complete list of what got stubbed has to be reportable per test, with the arguments each stubbed call was passed, because §21.3 rule 4 makes verification a query over what happened rather than an expectation set in advance.

A backend that cannot offer this says so by returning None from Backend::intercepting, and the harness reports that stubs are unavailable rather than running the test and lying about it.

Required Methods§

Source

fn intercept(&self, name: &str, args: &[Value]) -> Option<Value>

Called before a top-level definition named name is applied to args. Returning Some replaces the call; returning None runs the real body.

Implementors§