pub trait ConvergenceFixture {
type Projection: Projection;
type Codec: Codec;
// Required methods
fn projection(&self) -> Self::Projection;
fn codec(&self) -> &Self::Codec;
fn authored(&self) -> [Vec<EventOf<Self>>; 2];
fn store(&self) -> impl Future<Output = Result<StoreOf<Self>, Violation>>;
fn read_model(
&self,
store: &StoreOf<Self>,
) -> impl Future<Output = Result<Vec<u8>, Violation>>;
}Expand description
One projection, the events two origins authored, and a way to read what it committed.
The convergence family’s fixture, and a different shape from the peer and
ingest families’ because its subject is different: not an adapter but a
typed fold. The rule replays the two origins’ events in two interleavings
and runs a fresh projection over each into a fresh
store, so every method that builds something is called
once per interleaving and must build it anew.
§No convergence bound here, on purpose (SY-22)
Projection is bounded on Projection alone. The declaration is
required by the rule,
convergent_projection_is_interleaving_independent,
in its own where-clause, so a fixture over an undeclared projection can be
written and cannot be handed to it. That where-clause is the exclusion
SY-22 asks for, and CostLayersFixture is the honest case it excludes.
§The events are the check’s strength
The rule reorders what it is given and nothing else, so a fold that depends on arrival order is caught only by events whose order it depends on. Hand it two origins that disagree about something the fold keeps — the same key written from both sides, a quantity one consumes from the other — or the rule passes a fold it should not.
Required Associated Types§
Sourcetype Projection: Projection
type Projection: Projection
The projection under test, in either flavour.
Required Methods§
Sourcefn projection(&self) -> Self::Projection
fn projection(&self) -> Self::Projection
A fresh projection, in the state it starts a rebuild in.
Sourcefn codec(&self) -> &Self::Codec
fn codec(&self) -> &Self::Codec
The codec the rule encodes the events with and the runner decodes them with.
The events each origin authored, in authorship order: origin one’s, then origin two’s.
Neither may be empty. An origin with nothing to interleave makes the two interleavings the same log, and a check over one log is decorative, so the rule refuses that case rather than passing it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".