Table of Contents

Class NullableExtensionsAsync

Namespace
FunctionalDdd
Assembly
FunctionalDdd.RailwayOrientedProgramming.dll

Asynchronous extension methods for converting nullable values to Result types.

public static class NullableExtensionsAsync
Inheritance
NullableExtensionsAsync
Inherited Members

Remarks

These extensions allow you to convert tasks or value tasks returning potentially null values into Result types in an async context.

Methods

ToResultAsync<T>(Task<T?>, Error)

Converts a task returning a nullable value type to a Result asynchronously.

public static Task<Result<T>> ToResultAsync<T>(this Task<T?> nullableTask, Error errors) where T : struct

Parameters

nullableTask Task<T?>

The task returning a nullable value.

errors Error

The error to return if the value is null.

Returns

Task<Result<T>>

A task that represents the asynchronous operation. The task result is a success Result if the value is not null; otherwise a failure Result.

Type Parameters

T

The underlying value type.

ToResultAsync<T>(Task<T?>, Error)

Converts a task returning a nullable reference type to a Result asynchronously.

public static Task<Result<T>> ToResultAsync<T>(this Task<T?> nullableTask, Error errors) where T : class

Parameters

nullableTask Task<T>

The task returning a potentially null object.

errors Error

The error to return if the object is null.

Returns

Task<Result<T>>

A task that represents the asynchronous operation. The task result is a success Result if the object is not null; otherwise a failure Result.

Type Parameters

T

The reference type.

ToResultAsync<T>(ValueTask<T?>, Error)

Converts a ValueTask returning a nullable value type to a Result asynchronously.

public static ValueTask<Result<T>> ToResultAsync<T>(this ValueTask<T?> nullableTask, Error errors) where T : struct

Parameters

nullableTask ValueTask<T?>

The ValueTask returning a nullable value.

errors Error

The error to return if the value is null.

Returns

ValueTask<Result<T>>

A ValueTask that represents the asynchronous operation. The task result is a success Result if the value is not null; otherwise a failure Result.

Type Parameters

T

The underlying value type.

ToResultAsync<T>(ValueTask<T?>, Error)

Converts a ValueTask returning a nullable reference type to a Result asynchronously.

public static ValueTask<Result<T>> ToResultAsync<T>(this ValueTask<T?> nullableTask, Error errors) where T : class

Parameters

nullableTask ValueTask<T>

The ValueTask returning a potentially null object.

errors Error

The error to return if the object is null.

Returns

ValueTask<Result<T>>

A ValueTask that represents the asynchronous operation. The task result is a success Result if the object is not null; otherwise a failure Result.

Type Parameters

T

The reference type.