pub trait EventSink {
// Required method
fn emit(&mut self, event: RunEvent);
// Provided methods
fn delta(&mut self, node: &str, text: &str) { ... }
fn settled(&mut self, node: &str, kept: bool) { ... }
}Expand description
Where a run’s observable output goes.
Two channels, and the difference between them is the point.
emit carries the event stream: the record of what
the run did. It is ordered, it is timestamp-free, and replaying a cassette
reproduces it byte for byte, which is what lets a test assert on it.
delta and settled carry the
live channel: text as a model produces it. None of it is a record of
anything. How an answer arrived over the wire is a property of the
connection, not of the run, so a delta is never an event, never recorded in
a cassette, and never asserted on. Both default to discarding, so a sink
that only wants the record gets exactly the record.
Required Methods§
Provided Methods§
Sourcefn delta(&mut self, node: &str, text: &str)
fn delta(&mut self, node: &str, text: &str)
A fragment of a model’s answer, as it arrives.
Called only on a live call against a provider that streams. Fragments
for one node arrive in order and concatenate to the answer’s text; a
watcher that shows them is showing something that may yet be thrown
away, which is what settled is for.
Sourcefn settled(&mut self, node: &str, kept: bool)
fn settled(&mut self, node: &str, kept: bool)
No more deltas for this node, and whether the text became the answer.
kept is false when the response was discarded — the answer was cut
off, or it did not match its declared type — so a watcher can strike
what it showed instead of leaving a half-finished answer on screen
looking like a result. Called only after at least one delta.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".