Package-level declarations

Types

Link copied to clipboard
fun interface Callback<T>

A callback function receiving a value.

Link copied to clipboard
interface Future<V, E>

The output of an asynchronous operation.

Link copied to clipboard
sealed interface HttpError

An error occurring due to an HTTP request failing.

Link copied to clipboard
class Promise<V, E>(val thread: ThreadRef) : Future<V, E>

Represents an ongoing asynchronous operation.

Link copied to clipboard
sealed interface Result<out V, out E>

The result of an operation: either Result.Ok or Result.Err.

Link copied to clipboard
fun interface ResultCallback<V, E>

A callback function receiving a Result value.

Link copied to clipboard
abstract class VoiceError

An error occurring during an operation.

Link copied to clipboard
class VoiceException(val error: VoiceError) : Exception

Functions

Link copied to clipboard
inline fun <V, E> Result<V, E>.ifError(onError: (E) -> Unit)

Kotlin convenience method: invoke the callback if the result is an error.

Link copied to clipboard
inline fun <V, E> Result<V, E>.orError(onError: (E) -> Nothing): V

Kotlin convenience method: return the value if Ok, otherwise invoke the callback with the error.

Link copied to clipboard
fun <V, E> resolvedPromiseErr(thread: ThreadRef, error: E): Future<V, E>

Returns a Future which has already resolved with an error.

Link copied to clipboard
fun <V, E> resolvedPromiseOk(thread: ThreadRef, value: V): Future<V, E>

Returns a Future which has already resolved successfully.

Link copied to clipboard
fun <V, E> withPromise(thread: ThreadRef, action: (Promise<V, E>) -> Unit): Future<V, E>

Convenience method to create and return a Promise.

Link copied to clipboard

Returns a new Future which times out after the specified duration.