pub fn caching_operation_update_stream<'a, U, S>(
db: Database,
operation_id: OperationId,
stream: S,
is_terminal: impl Fn(&U) -> bool + MaybeSend + 'a,
) -> BoxStream<'a, U>Expand description
Wraps an operation update stream such that the last update before it closes
is tried to be written to the operation log entry as its outcome — but only
if is_terminal reports it as a final state of the operation. A stream
that ends on a non-terminal update (e.g. an error-path early return in the
stream generator) must not have that update cached as the outcome:
OperationLog::outcome_or_updates short-circuits every later subscriber
to the cached value, so caching a non-terminal update would freeze the
operation’s observable state before its actual end.