pub trait EventOf<I> {
type Aggregate;
// Required method
fn event(&self, item: I) -> Self::Aggregate;
}Expand description
One call of a many-item method: a stream of its items.
I is the item, P the progress type (NoProgress when the method
declares none), A the activation’s {Ns}Event aggregate. A generated
client spells all four — MethodStream<'_, Result<Row, ScanError>, NoProgress, TicketsEvent>; the defaults are for the macro-free
decode path.
It is a plain Stream<Item = Result<I, ClientError>> — a TryStream —
so futures’ combinators apply:
use futures::TryStreamExt;
let rows: Vec<Result<Row, ScanError>> = client.scan("a".into()).try_collect().await?;Progress frames are dropped undecoded unless the caller opts in with
with_progress; events turns
the call into the activation’s aggregate. See the module docs
for the decoding table.
Unpin, and Send wherever the transport’s item stream is (everywhere
but wasm32); dropping it mid-stream drops the wire stream, which cancels
the call on a transport that can (the WebSocket one unsubscribes).
How an item becomes its activation’s aggregate: the method’s variant.
A fn(I) -> A is one (TicketsEvent::List). The activation macro emits a
zero-sized one per many-item method (RETURNS-46), so the variant and the
lift above it are one inlined step per event — not a call through a
pointer and then the lift, which costs about 10 ns an event.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".