Class RecoverExtensionsAsync
- Namespace
- Trellis
- Assembly
- Trellis.Results.dll
Provides asynchronous extension methods for recovering from failures with a fallback value.
public static class RecoverExtensionsAsync
- Inheritance
-
RecoverExtensionsAsync
- Inherited Members
Methods
RecoverAsync<TValue>(Task<Result<TValue>>, Func<Error, TValue>)
Asynchronously recovers from a failure by calling a function that receives the error.
public static Task<Result<TValue>> RecoverAsync<TValue>(this Task<Result<TValue>> resultTask, Func<Error, TValue> fallbackFunc)
Parameters
resultTaskTask<Result<TValue>>The task producing the result to recover from.
fallbackFuncFunc<Error, TValue>The function that receives the error and produces a fallback value.
Returns
Type Parameters
TValueType of the result value.
RecoverAsync<TValue>(Task<Result<TValue>>, Func<TValue>)
Asynchronously recovers from a failure by calling a function to produce a fallback value.
public static Task<Result<TValue>> RecoverAsync<TValue>(this Task<Result<TValue>> resultTask, Func<TValue> fallbackFunc)
Parameters
resultTaskTask<Result<TValue>>The task producing the result to recover from.
fallbackFuncFunc<TValue>The function to produce a fallback value if the result is a failure.
Returns
Type Parameters
TValueType of the result value.
RecoverAsync<TValue>(Task<Result<TValue>>, TValue)
Asynchronously recovers from a failure by substituting a fallback value.
public static Task<Result<TValue>> RecoverAsync<TValue>(this Task<Result<TValue>> resultTask, TValue fallback)
Parameters
resultTaskTask<Result<TValue>>The task producing the result to recover from.
fallbackTValueThe fallback value to use if the result is a failure.
Returns
Type Parameters
TValueType of the result value.
RecoverAsync<TValue>(ValueTask<Result<TValue>>, Func<Error, TValue>)
Asynchronously recovers from a failure by calling a function that receives the error (ValueTask).
public static ValueTask<Result<TValue>> RecoverAsync<TValue>(this ValueTask<Result<TValue>> resultTask, Func<Error, TValue> fallbackFunc)
Parameters
resultTaskValueTask<Result<TValue>>The ValueTask producing the result to recover from.
fallbackFuncFunc<Error, TValue>The function that receives the error and produces a fallback value.
Returns
- ValueTask<Result<TValue>>
The original result if success; otherwise a success with the fallback value.
Type Parameters
TValueType of the result value.
RecoverAsync<TValue>(ValueTask<Result<TValue>>, Func<TValue>)
Asynchronously recovers from a failure by calling a function to produce a fallback value (ValueTask).
public static ValueTask<Result<TValue>> RecoverAsync<TValue>(this ValueTask<Result<TValue>> resultTask, Func<TValue> fallbackFunc)
Parameters
resultTaskValueTask<Result<TValue>>The ValueTask producing the result to recover from.
fallbackFuncFunc<TValue>The function to produce a fallback value if the result is a failure.
Returns
- ValueTask<Result<TValue>>
The original result if success; otherwise a success with the fallback value.
Type Parameters
TValueType of the result value.
RecoverAsync<TValue>(ValueTask<Result<TValue>>, TValue)
Asynchronously recovers from a failure by substituting a fallback value (ValueTask).
public static ValueTask<Result<TValue>> RecoverAsync<TValue>(this ValueTask<Result<TValue>> resultTask, TValue fallback)
Parameters
resultTaskValueTask<Result<TValue>>The ValueTask producing the result to recover from.
fallbackTValueThe fallback value to use if the result is a failure.
Returns
- ValueTask<Result<TValue>>
The original result if success; otherwise a success with the fallback value.
Type Parameters
TValueType of the result value.