AdminResult

sealed interface AdminResult<out T>(source)

Result of an admin (configuration) RPC operation.

Admin operations can fail for expected reasons (device unreachable, unauthorized, timeout) without throwing an exception.

Since

0.1.0

Inheritors

Types

Link copied to clipboard
data class Failed(val routingError: Routing.Error) : AdminResult<Nothing>

Device reported a routing error.

Link copied to clipboard

Destination node is unreachable.

Link copied to clipboard

The device rate-limited the request; back off before retrying.

Link copied to clipboard

Session key expired or was never established.

Link copied to clipboard
data class Success<T>(val value: T) : AdminResult<T>

Operation succeeded.

Link copied to clipboard
data object Timeout : AdminResult<Nothing>

Operation timed out waiting for a device response.

Link copied to clipboard

Client is not authorized to perform this operation.

Properties

Link copied to clipboard

Returns true if this is AdminResult.Success.

Functions

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

Applies onSuccess or onFailure depending on the result.

Link copied to clipboard
fun <T> AdminResult<T>.getOrElse(default: T): T

Returns the Success value, or default if the result is not a success.

inline fun <T> AdminResult<T>.getOrElse(block: (AdminResult<T>) -> T): T

Returns the Success value, or the result of block if the result is not a success.

Link copied to clipboard

Returns the Success value, or null if the result is not a success.

Link copied to clipboard

Returns the Success value or throws AdminResultException describing the failure.

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

Transforms the Success value with transform, propagating failures unchanged.

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

Performs action if this is not a Success. Returns the original result for chaining.

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

Performs action if this is a Success. Returns the original result for chaining.