Success

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

Constructors

Link copied to clipboard
constructor(value: T)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val value: T

Functions

Link copied to clipboard

The error, or null on success.

Link copied to clipboard
inline fun <R> flatMap(transform: (T) -> SolidResult<R>): SolidResult<R>

Chains an operation that itself returns a SolidResult, propagating a failure unchanged.

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

Collapses both variants to a single R.

Link copied to clipboard
fun getOrDefault(default: T): T

The success value, or default on failure.

Link copied to clipboard
inline fun getOrElse(onFailure: (SolidError) -> T): T

The success value, or the result of onFailure applied to the error.

Link copied to clipboard
fun getOrNull(): T?

The success value, or null on failure.

Link copied to clipboard
fun getOrThrow(): T

The success value, or throws SolidResultException carrying the error (and its cause).

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

Transforms the success value, propagating a failure unchanged.

Link copied to clipboard
inline fun onFailure(action: (SolidError) -> Unit): SolidResult<T>

Runs action on the error and returns this result unchanged.

Link copied to clipboard
inline fun onSuccess(action: (T) -> Unit): SolidResult<T>

Runs action on the success value and returns this result unchanged.

Link copied to clipboard
inline fun recover(transform: (SolidError) -> T): SolidResult<T>

Recovers a failure to a success value; a success passes through unchanged.