Skip to main content

EventOf

Trait EventOf 

Source
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§

Source

type Aggregate

The activation’s aggregate.

Required Methods§

Source

fn event(&self, item: I) -> Self::Aggregate

item as its aggregate.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<I, A> EventOf<I> for fn(I) -> A

Source§

type Aggregate = A

Source§

fn event(&self, item: I) -> A

Implementors§