Result

Functional Result class with HTTP status information.

Author

Jan Müller
sealed class Result<T : Any>

Parameters

T
The type of the data.

Types

Companion
Link copied to clipboard
object Companion
Failure
Link copied to clipboard
Result class for unsuccessful operations.
class Failure<T : Any> (error: String,status: HttpStatusCode) : Result
Success
Link copied to clipboard
Result class for successful operations.
class Success<T : Any> (data: T,status: HttpStatusCode) : Result

Functions

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open override fun hashCode(): Int
toString
Link copied to clipboard
open override fun toString(): String

Properties

status
Link copied to clipboard
The HTTP status code.
val status: HttpStatusCode

Inheritors

Result
Link copied to clipboard
Result
Link copied to clipboard

Extensions

andThen
Link copied to clipboard
Transforms the data of Results if they are Result.Successes.
suspend fun <T : Any, U : Any> Result<T>.andThen(transformation: SuspendFunction1<T, Result<U>>): Result<U>
map
Link copied to clipboard
Transforms the data of Results if they are Result.Successes.
suspend fun <T : Any, U : Any> Result<T>.map(transformation: SuspendFunction1<T, U>): Result<U>
mapFailureStatus
Link copied to clipboard
Transforms the failure status of Results if they are Result.Failures.
suspend fun <T : Any> Result<T>.mapFailureStatus(transformation: SuspendFunction1<HttpStatusCode, HttpStatusCode>): Result<T>
withResult
Link copied to clipboard
Consumes the data of Results if they are Result.Successes.
suspend fun <T : Any> Result<T>.withResult(consumer: SuspendFunction1<T, Unit>): Result<T>