Skip to main content

Observe

Trait Observe 

Source
pub trait Observe: Send + Sync {
    // Required methods
    fn outcome(&mut self, outcome: Result<Answered, ErrorReport>);
    fn keep_events(&self) -> bool;
    fn event(&mut self, item: &Item<StreamEvent>);
    fn origin(&mut self, origin: &Origin);
    fn discard(&mut self, layer: &str);
    fn patch(&mut self, kind: &EffectKind);

    // Provided methods
    fn adapter_context(&self) -> Option<AdapterContext> { ... }
    fn stream_error(&mut self, _error: &ErrorReport) { ... }
    fn stream_item(
        &mut self,
        item: &Result<Relayed, ErrorReport>,
        outcome: Option<Result<Answered, ErrorReport>>,
    ) { ... }
}
Expand description

What an observer of one dispatch sees: its outcome and, when wanted, each streamed item.

Required Methods§

Source

fn outcome(&mut self, outcome: Result<Answered, ErrorReport>)

The completed handler response, or the fold of a streaming handler’s events. A resolved response retains content that has no stream block, such as images emitted as unknown events.

Source

fn keep_events(&self) -> bool

Whether streamed items are wanted verbatim (Self::event).

Source

fn event(&mut self, item: &Item<StreamEvent>)

One item pulled from the original handler stream. This is recording evidence, not acknowledgement that a consumer received the item.

Source

fn origin(&mut self, origin: &Origin)

Who a streamed reply is from, before its first item. Required, so a recording observer cannot drop it: a replayed stream cut short needs it to know its origin.

Source

fn discard(&mut self, layer: &str)

The dispatch was decided before any handler served it, by the layer named: the record it opened is forgotten.

Source

fn patch(&mut self, kind: &EffectKind)

The layer named serves kind in place of the effect that began (same family): the record’s request is what the innermost handler served.

Provided Methods§

Source

fn adapter_context(&self) -> Option<AdapterContext>

Provider witness associated with this dispatch, independently of recording.

Source

fn stream_error(&mut self, _error: &ErrorReport)

An error item in a kept stream.

Source

fn stream_item( &mut self, item: &Result<Relayed, ErrorReport>, outcome: Option<Result<Answered, ErrorReport>>, )

Observe one stream item together with its first folded outcome, if any. Drivers that snapshot recording concurrently with cancellation can override this operation to make the item and its answer one observation boundary.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§