asResult

fun <T> Flow<T>.asResult(): Flow<Result<T>>

Wraps each upstream value in Result.success and a terminal upstream failure in a single Result.failure.

After a failure is emitted the flow completes normally, so collectors never observe an exception from the upstream. Cancellation is not wrapped and propagates as usual.