Success

data class Success<out T>(val value: T) : DataResult<T>

Represents successful operation execution.

Constructors

Link copied to clipboard
constructor(value: T)

Properties

Link copied to clipboard
val value: T

Functions

Link copied to clipboard
fun <R, T : R> DataResult<T>.getOrElse(onFailure: (Throwable) -> R): R

Returns the value if the result is Success, or computes a default value from the error if it is Failure.

Link copied to clipboard

Returns the value if the result is Success, or throws an exception if it is Failure.

Link copied to clipboard
inline fun <T, R> DataResult<T>.map(transform: (T) -> R): DataResult<R>

Transforms the value inside DataResult.Success, leaving DataResult.Failure unchanged.

Link copied to clipboard

Executes an action if the result is Failure, without modifying the original error.

Link copied to clipboard
fun <T> DataResult<T>.onSuccess(action: (T) -> Unit): DataResult<T>

Executes an action if the result is Success, without modifying the original value.