Failure

data class Failure(val error: BleException) : BleResult<Nothing>

Represents a failed BLE operation result.

Constructors

Link copied to clipboard
constructor(error: BleException)

Properties

Link copied to clipboard

The BleException describing the failure.

Link copied to clipboard

Returns true if this result represents a failed operation.

Link copied to clipboard

Returns true if this result represents a successful operation.

Functions

Link copied to clipboard

Returns the exception if this is a Failure, or null if this is a Success.

Link copied to clipboard
inline fun <R> flatMap(transform: (Nothing) -> BleResult<R>): BleResult<R>

Transforms the success value using a function that returns a BleResult.

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

Folds the result into a single value by applying the appropriate function.

Link copied to clipboard
fun getOrDefault(defaultValue: Nothing): Nothing

Returns the success value if this is a Success, or the defaultValue if this is a Failure.

Link copied to clipboard
inline fun getOrElse(defaultValue: (BleException) -> Nothing): Nothing

Returns the success value if this is a Success, or the result of defaultValue if this is a Failure.

Link copied to clipboard

Returns the success value if this is a Success, or null if this is a Failure.

Link copied to clipboard

Returns the success value if this is a Success, or throws the exception if this is a Failure.

Link copied to clipboard
inline fun <R> map(transform: (Nothing) -> R): BleResult<R>

Transforms the success value using the given transform function.

Link copied to clipboard
inline fun mapError(transform: (BleException) -> BleException): BleResult<Nothing>

Transforms the error using the given transform function.

Link copied to clipboard
inline fun onFailure(action: (BleException) -> Unit): BleResult<Nothing>

Performs the given action if this is a Failure.

Link copied to clipboard
inline fun onSuccess(action: (Nothing) -> Unit): BleResult<Nothing>

Performs the given action if this is a Success.

Link copied to clipboard
inline fun recover(recovery: (BleException) -> Nothing): BleResult<Nothing>

Recovers from a failure by providing an alternative success value.

Link copied to clipboard

Attempts to recover from a failure using another BleResult.

Link copied to clipboard
fun <T, R> BleResult<T>.zip(other: BleResult<R>): BleResult<Pair<T, R>>

Combines two BleResult instances into a single result containing a Pair.