Table of Contents

Class CheckExtensionsAsync

Namespace
Trellis
Assembly
Trellis.Results.dll

Async Check extensions where BOTH input and check function are async (Task).

public static class CheckExtensionsAsync
Inheritance
CheckExtensionsAsync
Inherited Members

Remarks

Users should capture CancellationToken in their lambda closures when cancellation support is needed.

Methods

CheckAsync<T>(Task<Result<T>>, Func<T, Task<Result<Unit>>>)

Asynchronously runs a validation function that returns Result<TValue> on the success value, preserving the original value on success. Both the input and the check function are async.

public static Task<Result<T>> CheckAsync<T>(this Task<Result<T>> resultTask, Func<T, Task<Result<Unit>>> func)

Parameters

resultTask Task<Result<T>>

The task containing the result to check.

func Func<T, Task<Result<Unit>>>

The async validation function that returns a Result of Unit.

Returns

Task<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

CheckAsync<T>(Task<Result<T>>, Func<T, Result<Unit>>)

Asynchronously runs a sync validation function that returns Result<TValue> on the success value, preserving the original value on success. Only the input is async; the check function is sync.

public static Task<Result<T>> CheckAsync<T>(this Task<Result<T>> resultTask, Func<T, Result<Unit>> func)

Parameters

resultTask Task<Result<T>>

The task containing the result to check.

func Func<T, Result<Unit>>

The sync validation function that returns a Result of Unit.

Returns

Task<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

CheckAsync<T>(ValueTask<Result<T>>, Func<T, ValueTask<Result<Unit>>>)

Asynchronously runs a validation function that returns Result<TValue> on the success value, preserving the original value on success. Both the input and the check function are async (ValueTask).

public static ValueTask<Result<T>> CheckAsync<T>(this ValueTask<Result<T>> resultTask, Func<T, ValueTask<Result<Unit>>> func)

Parameters

resultTask ValueTask<Result<T>>

The async result to check.

func Func<T, ValueTask<Result<Unit>>>

The async validation function that returns a Result of Unit.

Returns

ValueTask<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

CheckAsync<T>(ValueTask<Result<T>>, Func<T, Result<Unit>>)

Asynchronously runs a sync validation function that returns Result<TValue> on the success value, preserving the original value on success. Only the input is async (ValueTask); the check function is sync.

public static ValueTask<Result<T>> CheckAsync<T>(this ValueTask<Result<T>> resultTask, Func<T, Result<Unit>> func)

Parameters

resultTask ValueTask<Result<T>>

The async result to check.

func Func<T, Result<Unit>>

The sync validation function that returns a Result of Unit.

Returns

ValueTask<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

CheckAsync<T>(Result<T>, Func<T, Task<Result<Unit>>>)

Runs an async validation function that returns Result<TValue> on the sync success value, preserving the original value on success. Only the check function is async; the input is sync.

public static Task<Result<T>> CheckAsync<T>(this Result<T> result, Func<T, Task<Result<Unit>>> func)

Parameters

result Result<T>

The result to check.

func Func<T, Task<Result<Unit>>>

The async validation function that returns a Result of Unit.

Returns

Task<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

CheckAsync<T>(Result<T>, Func<T, ValueTask<Result<Unit>>>)

Runs an async validation function that returns Result<TValue> on the sync success value, preserving the original value on success. Only the check function is async (ValueTask); the input is sync.

public static ValueTask<Result<T>> CheckAsync<T>(this Result<T> result, Func<T, ValueTask<Result<Unit>>> func)

Parameters

result Result<T>

The result to check.

func Func<T, ValueTask<Result<Unit>>>

The async validation function that returns a Result of Unit.

Returns

ValueTask<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

CheckAsync<T, TK>(Task<Result<T>>, Func<T, Task<Result<TK>>>)

Asynchronously runs a validation function on the success value, discarding the check result's value on success and preserving the original value. If the check fails, its failure is returned. Both the input and the check function are async.

public static Task<Result<T>> CheckAsync<T, TK>(this Task<Result<T>> resultTask, Func<T, Task<Result<TK>>> func)

Parameters

resultTask Task<Result<T>>

The task containing the result to check.

func Func<T, Task<Result<TK>>>

The async validation function that returns a Result.

Returns

Task<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

TK

Type of the check function's result value (discarded on success).

CheckAsync<T, TK>(Task<Result<T>>, Func<T, Result<TK>>)

Asynchronously runs a sync validation function on the success value, discarding the check result's value on success and preserving the original value. If the check fails, its failure is returned. Only the input is async; the check function is sync.

public static Task<Result<T>> CheckAsync<T, TK>(this Task<Result<T>> resultTask, Func<T, Result<TK>> func)

Parameters

resultTask Task<Result<T>>

The task containing the result to check.

func Func<T, Result<TK>>

The sync validation function that returns a Result.

Returns

Task<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

TK

Type of the check function's result value (discarded on success).

CheckAsync<T, TK>(ValueTask<Result<T>>, Func<T, ValueTask<Result<TK>>>)

Asynchronously runs a validation function on the success value, discarding the check result's value on success and preserving the original value. If the check fails, its failure is returned. Both the input and the check function are async (ValueTask).

public static ValueTask<Result<T>> CheckAsync<T, TK>(this ValueTask<Result<T>> resultTask, Func<T, ValueTask<Result<TK>>> func)

Parameters

resultTask ValueTask<Result<T>>

The async result to check.

func Func<T, ValueTask<Result<TK>>>

The async validation function that returns a Result.

Returns

ValueTask<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

TK

Type of the check function's result value (discarded on success).

CheckAsync<T, TK>(ValueTask<Result<T>>, Func<T, Result<TK>>)

Asynchronously runs a sync validation function on the success value, discarding the check result's value on success and preserving the original value. If the check fails, its failure is returned. Only the input is async (ValueTask); the check function is sync.

public static ValueTask<Result<T>> CheckAsync<T, TK>(this ValueTask<Result<T>> resultTask, Func<T, Result<TK>> func)

Parameters

resultTask ValueTask<Result<T>>

The async result to check.

func Func<T, Result<TK>>

The sync validation function that returns a Result.

Returns

ValueTask<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

TK

Type of the check function's result value (discarded on success).

CheckAsync<T, TK>(Result<T>, Func<T, Task<Result<TK>>>)

Runs an async validation function on the sync success value, discarding the check result's value on success and preserving the original value. If the check fails, its failure is returned. Only the check function is async; the input is sync.

public static Task<Result<T>> CheckAsync<T, TK>(this Result<T> result, Func<T, Task<Result<TK>>> func)

Parameters

result Result<T>

The result to check.

func Func<T, Task<Result<TK>>>

The async validation function that returns a Result.

Returns

Task<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

TK

Type of the check function's result value (discarded on success).

CheckAsync<T, TK>(Result<T>, Func<T, ValueTask<Result<TK>>>)

Runs an async validation function on the sync success value, discarding the check result's value on success and preserving the original value. If the check fails, its failure is returned. Only the check function is async (ValueTask); the input is sync.

public static ValueTask<Result<T>> CheckAsync<T, TK>(this Result<T> result, Func<T, ValueTask<Result<TK>>> func)

Parameters

result Result<T>

The result to check.

func Func<T, ValueTask<Result<TK>>>

The async validation function that returns a Result.

Returns

ValueTask<Result<T>>

The original result if the check passes; otherwise the check's failure.

Type Parameters

T

Type of the original result value.

TK

Type of the check function's result value (discarded on success).