Table of Contents

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

resultTask Task<Result<TValue>>

The task producing the result to recover from.

fallbackFunc Func<Error, TValue>

The function that receives the error and produces a fallback value.

Returns

Task<Result<TValue>>

The original result if success; otherwise a success with the fallback value.

Type Parameters

TValue

Type 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

resultTask Task<Result<TValue>>

The task producing the result to recover from.

fallbackFunc Func<TValue>

The function to produce a fallback value if the result is a failure.

Returns

Task<Result<TValue>>

The original result if success; otherwise a success with the fallback value.

Type Parameters

TValue

Type 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

resultTask Task<Result<TValue>>

The task producing the result to recover from.

fallback TValue

The fallback value to use if the result is a failure.

Returns

Task<Result<TValue>>

The original result if success; otherwise a success with the fallback value.

Type Parameters

TValue

Type 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

resultTask ValueTask<Result<TValue>>

The ValueTask producing the result to recover from.

fallbackFunc Func<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

TValue

Type 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

resultTask ValueTask<Result<TValue>>

The ValueTask producing the result to recover from.

fallbackFunc Func<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

TValue

Type 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

resultTask ValueTask<Result<TValue>>

The ValueTask producing the result to recover from.

fallback TValue

The 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

TValue

Type of the result value.