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§
Sourcefn outcome(&mut self, outcome: Result<Answered, ErrorReport>)
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.
Sourcefn keep_events(&self) -> bool
fn keep_events(&self) -> bool
Whether streamed items are wanted verbatim (Self::event).
Sourcefn event(&mut self, item: &Item<StreamEvent>)
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.
Sourcefn origin(&mut self, origin: &Origin)
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.
Sourcefn discard(&mut self, layer: &str)
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.
Sourcefn patch(&mut self, kind: &EffectKind)
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§
Sourcefn adapter_context(&self) -> Option<AdapterContext>
fn adapter_context(&self) -> Option<AdapterContext>
Provider witness associated with this dispatch, independently of recording.
Sourcefn stream_error(&mut self, _error: &ErrorReport)
fn stream_error(&mut self, _error: &ErrorReport)
An error item in a kept stream.
Sourcefn stream_item(
&mut self,
item: &Result<Relayed, ErrorReport>,
outcome: Option<Result<Answered, ErrorReport>>,
)
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".