Class MaybeExtensionsAsync
- Namespace
- FunctionalDdd
- Assembly
- FunctionalDdd.RailwayOrientedProgramming.dll
Provides asynchronous extension methods for converting Maybe<T> instances to Result<TValue>.
public static class MaybeExtensionsAsync
- Inheritance
-
MaybeExtensionsAsync
- Inherited Members
Methods
ToResultAsync<TValue>(Task<Maybe<TValue>>, Error)
Asynchronously converts a Maybe<T> to a Result<TValue>. If the Maybe has a value, returns success; otherwise, returns failure with the specified error.
public static Task<Result<TValue>> ToResultAsync<TValue>(this Task<Maybe<TValue>> maybeTask, Error error) where TValue : notnull
Parameters
maybeTaskTask<Maybe<TValue>>The task containing the Maybe instance to convert.
errorErrorThe error to return if the Maybe has no value.
Returns
Type Parameters
TValueType of the value contained in Maybe.
ToResultAsync<TValue>(Task<Maybe<TValue>>, Func<Error>)
Asynchronously converts a Maybe<T> to a Result<TValue> using a function to create the error. If the Maybe has a value, returns success; otherwise, returns failure with an error from the function.
public static Task<Result<TValue>> ToResultAsync<TValue>(this Task<Maybe<TValue>> maybeTask, Func<Error> ferror) where TValue : notnull
Parameters
maybeTaskTask<Maybe<TValue>>The task containing the Maybe instance to convert.
ferrorFunc<Error>A function that produces the error if the Maybe has no value.
Returns
- Task<Result<TValue>>
A task containing a Result with the Maybe's value or an error from the function.
Type Parameters
TValueType of the value contained in Maybe.
ToResultAsync<TValue>(ValueTask<Maybe<TValue>>, Error)
Asynchronously converts a Maybe<T> to a Result<TValue> using a ValueTask. If the Maybe has a value, returns success; otherwise, returns failure with the specified error.
public static ValueTask<Result<TValue>> ToResultAsync<TValue>(this ValueTask<Maybe<TValue>> maybeTask, Error error) where TValue : notnull
Parameters
maybeTaskValueTask<Maybe<TValue>>The ValueTask containing the Maybe instance to convert.
errorErrorThe error to return if the Maybe has no value.
Returns
- ValueTask<Result<TValue>>
A ValueTask containing a Result with the Maybe's value or the specified error.
Type Parameters
TValueType of the value contained in Maybe.
ToResultAsync<TValue>(ValueTask<Maybe<TValue>>, Func<Error>)
Asynchronously converts a Maybe<T> to a Result<TValue> using a ValueTask and a function to create the error. If the Maybe has a value, returns success; otherwise, returns failure with an error from the function.
public static ValueTask<Result<TValue>> ToResultAsync<TValue>(this ValueTask<Maybe<TValue>> maybeTask, Func<Error> ferror) where TValue : notnull
Parameters
maybeTaskValueTask<Maybe<TValue>>The ValueTask containing the Maybe instance to convert.
ferrorFunc<Error>A function that produces the error if the Maybe has no value.
Returns
- ValueTask<Result<TValue>>
A ValueTask containing a Result with the Maybe's value or an error from the function.
Type Parameters
TValueType of the value contained in Maybe.