A discriminated union of channel operation result. It encapsulates the successful or failed result of a channel operation or a failed operation to a closed channel with an optional cause.
The successful result represents a successful operation with a value of type T, for example, the result of Channel.receiveCatching operation or a successfully sent element as a result of Channel.trySend.
The failed result represents a failed operation attempt to a channel, but it doesn't necessary indicate that the channel is failed. E.g. when the channel is full, Channel.trySend returns failed result, but the channel itself is not in the failed state.
The closed result represents an operation attempt to a closed channel and also implies that the operation has failed. It is guaranteed that if the result is closed, then the target channel is either closed for send or is closed for receive depending on whether the failed operation was sending or receiving.
Performs the given action on the encapsulated Throwable exception if this instance represents failure due to channel being closed. The result of ChannelResult.exceptionOrNull is passed to the action parameter. It is guaranteed that if action is invoked, then the channel is either closed for send or is closed for receive depending on the failed operation.