ResultFutureRedirector<T extends Object, E extends Object> extension

enable Result<T, E> methods in a Future<Result<T, E>>

on

Methods

and<U extends Object>(Result<U, E> res) Future<Result<U, E>>
Returns res if the result is Ok, otherwise returns this.
andThen<U extends Object>(Result<U, E> op(T)) Future<Result<U, E>>
Calls op with the Ok value if the result is Ok, otherwise returns this.
andThenAsync<U extends Object>(Future<Result<U, E>> op(T)) Future<Result<U, E>>
Asynchronously calls op with the Ok value if the result is Ok, otherwise returns this.
err() Future<Option<E>>
Converts the Result into an Option containing the error, if any. Otherwise returns None if the result is a value.
expect(String msg) Future<T>
Unwraps a result, yielding the content of an Ok.
expectErr(String msg) Future<E>
Unwraps a result, yielding the content of an Err.
fold<U extends Object, F extends Object>(U ok(T), F err(E)) Future<Result<U, F>>
Invoke either the ok or the err function based on the result.
foldAsync<U extends Object, F extends Object>(Future<U> ok(T), Future<F> err(E)) Future<Result<U, F>>
Asynchronously invoke either the ok or the err function based on the result.
isErr() Future<bool>
Returns true if the option is a Err value.
isOk() Future<bool>
Returns true if the option is a Ok value.
map<U extends Object>(U op(T)) Future<Result<U, E>>
Maps a Result<T, E> to Result<U, E> by applying a function to a contained Ok value, leaving an Err value untouched.
mapAsync<U extends Object>(Future<U> op(T)) Future<Result<U, E>>
Maps a Result<T, E> to Result<U, E> by applying an asynchronous function to a contained Ok value, leaving an Err value untouched.
mapErr<F extends Object>(F op(E)) Future<Result<T, F>>
Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving an Ok value untouched.
mapErrAsync<F extends Object>(Future<F> op(E)) Future<Result<T, F>>
Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving an Ok value untouched.
mapOr<U>(U op(T), U opt) Future<U>
Applies a function to the contained value (if any), or returns the provided default (if not).
mapOrAsync<U>(Future<U> op(T), U opt) Future<U>
Applies an asynchronous function to the contained value (if any), or returns the provided default (if not).
mapOrElse<U>(U op(T), U errOp(E)) Future<U>
Maps a Result<T, E> to U by applying a function to a contained Ok value, or a fallback function to a contained Err value.
mapOrElseAsync<U>(Future<U> op(T), Future<U> errOp(E)) Future<U>
Maps a Result<T, E> to U by applying a function to a contained Ok value, or a fallback function to a contained Err value.
match<R>(R okop(T), R errop(E)) Future<R>
Invokes either the okop or the errop depending on the result.
matchAsync<R>(Future<R> okop(T), Future<R> errop(E)) Future<R>
Asynchronously invokes either the okop or the errop depending on the result.
matchErr<R>(R errop(E)) Future<R?>
Invokes the errop if the result is Err, otherwise does nothing.
matchOk<R>(R okop(T)) Future<R?>
Invokes the okop if the result is Ok, otherwise does nothing.
ok() Future<Option<T>>
Converts the Result into an Option containing the value, if any. Otherwise returns None if the result is an error.
or<F extends Object>(Result<T, F> res) Future<Result<T, F>>
Returns res if the result is an Err, otherwise returns this.
orElse<F extends Object>(Result<T, F> op(E)) Future<Result<T, F>>
Calls op with the Err value if the result is Err, otherwise returns this.
orElseAsync<F extends Object>(Future<Result<T, F>> op(E)) Future<Result<T, F>>
Calls op with the Err value if the result is Err, otherwise returns this.
unwrap() Future<T>
Unwraps a result, yielding the content of an Ok.
unwrapErr() Future<E>
Unwraps a result, yielding the content of an Err.
unwrapOr(T opt) Future<T>
Unwraps a result, yielding the content of an Ok. Else, it returns opt.
unwrapOrElse(T op(E)) Future<T>
Unwraps a result, yielding the content of an Ok. If the value is an Err then it calls op with its value.
unwrapOrElseAsync(Future<T> op(E)) Future<T>
Unwraps a result, yielding the content of an Ok. If the value is an Err then it asynchronously calls op with its value.
unwrapOrNull() Future<T?>
Unwraps a result, yielding the content of an Ok.
when<R>({required R ok(T), required R err(E)}) Future<R>
Invokes either ok or err depending on the result.
whenAsync<R>({required Future<R> ok(T), required Future<R> err(E)}) Future<R>
Asynchronously invokes either ok or err depending on the result.