Success

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

The operation succeeded; value is the result.

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

Returns the error on failure, or null on success.

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

Returns onSuccess of the value or onFailure of the error; exactly one of them runs. The usual way to turn a result into your own type:

Link copied to clipboard

Returns the value on success, or null on failure.

Link copied to clipboard

Returns the value on success, or throws a PasskeyException carrying the error.

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

Transforms the value on success; failures pass through unchanged.

Link copied to clipboard

Transforms the error on failure, e.g. into another PasskeyError; successes pass through unchanged.

Link copied to clipboard
inline fun <T> PasskeyResult<T>.onFailure(action: (PasskeyError) -> Unit): PasskeyResult<T>

Runs action with the error if this is a PasskeyResult.Failure; returns this result unchanged.

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

Runs action with the value if this is a PasskeyResult.Success; returns this result unchanged.

Link copied to clipboard
inline fun <T> PasskeyResult<T>.recover(transform: (PasskeyError) -> T): PasskeyResult<T>

Turns any failure into a success with transform's value; successes pass through unchanged. It hides setup errors too, so log them in transform (or use fold when failures need their own handling):

Link copied to clipboard

The same outcome as a kotlin.Result; a failure holds a PasskeyException whose error is the original error. For code built around Result (e.g. runCatching chains).