KmmResult

sealed class KmmResult<out T>

For easy use of this KMM library under iOS, we need a class like Result that is not a value class (which is unsupported in Kotlin/Native)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
Link copied to clipboard
class Success<T> : KmmResult<T>

Functions

Link copied to clipboard
inline fun exceptionOrNull(): Throwable?

Returns the encapsulated Throwable exception if this instance represents failure or null if it is success.

Link copied to clipboard
inline fun <R> fold(onSuccess: (value: T) -> R, onFailure: (exception: Throwable) -> R): R

Returns the result of onSuccess for the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated Throwable exception if it is failure.

Link copied to clipboard
inline fun <R : @UnsafeVariance T> getOrElse(onFailure: (exception: Throwable) -> R): T

Returns the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated Throwable exception if it is failure.

Link copied to clipboard
fun getOrNull(): T?

Returns the encapsulated value if this instance represents success or null if it is failure.

Link copied to clipboard
fun getOrThrow(): T

Returns the encapsulated value if this instance represents success or throws the encapsulated Throwable exception if it is failure.

Link copied to clipboard
inline fun <R : Any> map(block: (T) -> R): KmmResult<R>

Transforms this KmmResult's success-case according to block and leaves the failure case untouched (type erasure FTW!)

Link copied to clipboard
inline fun mapFailure(block: (Throwable) -> Throwable): KmmResult<T>

Transforms this KmmResult's failure-case according to block and leaves the success case untouched (type erasure FTW!)

Link copied to clipboard
inline fun unwrap(): Result<T>

Returns a Result equivalent of this KmmResult

Properties

Link copied to clipboard

Returns true if this instance represents a failed outcome. In this case isSuccess returns false.

Link copied to clipboard

Returns true if this instance represents a successful outcome. In this case isFailure returns false.

Inheritors

Link copied to clipboard
Link copied to clipboard