Table of Contents

Class MapExtensionsAsync

Namespace
FunctionalDdd
Assembly
FunctionalDdd.RailwayOrientedProgramming.dll

Provides asynchronous extension methods for mapping (transforming) values inside Result objects.

public static class MapExtensionsAsync
Inheritance
MapExtensionsAsync
Inherited Members

Methods

MapAsync<TIn, TOut>(Result<TIn>, Func<TIn, Task<TOut>>)

Asynchronously maps the value of a successful result to a new value using the provided async function.

public static Task<Result<TOut>> MapAsync<TIn, TOut>(this Result<TIn> result, Func<TIn, Task<TOut>> func)

Parameters

result Result<TIn>

The result to map.

func Func<TIn, Task<TOut>>

The async function to transform the value if the result is successful.

Returns

Task<Result<TOut>>

A new success result with the transformed value if success; otherwise the original failure.

Type Parameters

TIn

Type of the input result value.

TOut

Type of the output result value.

MapAsync<TIn, TOut>(Result<TIn>, Func<TIn, ValueTask<TOut>>)

Asynchronously maps the value of a successful result to a new value using a ValueTask function.

public static ValueTask<Result<TOut>> MapAsync<TIn, TOut>(this Result<TIn> result, Func<TIn, ValueTask<TOut>> func)

Parameters

result Result<TIn>

The result to map.

func Func<TIn, ValueTask<TOut>>

The async function to transform the value if the result is successful.

Returns

ValueTask<Result<TOut>>

A new success result with the transformed value if success; otherwise the original failure.

Type Parameters

TIn

Type of the input result value.

TOut

Type of the output result value.

MapAsync<TIn, TOut>(Task<Result<TIn>>, Func<TIn, Task<TOut>>)

Asynchronously maps the value of a task result to a new value using an async function.

public static Task<Result<TOut>> MapAsync<TIn, TOut>(this Task<Result<TIn>> resultTask, Func<TIn, Task<TOut>> func)

Parameters

resultTask Task<Result<TIn>>

The task containing the result to map.

func Func<TIn, Task<TOut>>

The async function to transform the value if the result is successful.

Returns

Task<Result<TOut>>

A new success result with the transformed value if success; otherwise the original failure.

Type Parameters

TIn

Type of the input result value.

TOut

Type of the output result value.

MapAsync<TIn, TOut>(Task<Result<TIn>>, Func<TIn, TOut>)

Asynchronously maps the value of a task result to a new value using a synchronous function.

public static Task<Result<TOut>> MapAsync<TIn, TOut>(this Task<Result<TIn>> resultTask, Func<TIn, TOut> func)

Parameters

resultTask Task<Result<TIn>>

The task containing the result to map.

func Func<TIn, TOut>

The function to transform the value if the result is successful.

Returns

Task<Result<TOut>>

A new success result with the transformed value if success; otherwise the original failure.

Type Parameters

TIn

Type of the input result value.

TOut

Type of the output result value.

MapAsync<TIn, TOut>(ValueTask<Result<TIn>>, Func<TIn, ValueTask<TOut>>)

Asynchronously maps the value of a ValueTask result to a new value using an async function.

public static ValueTask<Result<TOut>> MapAsync<TIn, TOut>(this ValueTask<Result<TIn>> resultTask, Func<TIn, ValueTask<TOut>> func)

Parameters

resultTask ValueTask<Result<TIn>>

The ValueTask containing the result to map.

func Func<TIn, ValueTask<TOut>>

The async function to transform the value if the result is successful.

Returns

ValueTask<Result<TOut>>

A new success result with the transformed value if success; otherwise the original failure.

Type Parameters

TIn

Type of the input result value.

TOut

Type of the output result value.

MapAsync<TIn, TOut>(ValueTask<Result<TIn>>, Func<TIn, TOut>)

Asynchronously maps the value of a ValueTask result to a new value using a synchronous function.

public static ValueTask<Result<TOut>> MapAsync<TIn, TOut>(this ValueTask<Result<TIn>> resultTask, Func<TIn, TOut> func)

Parameters

resultTask ValueTask<Result<TIn>>

The ValueTask containing the result to map.

func Func<TIn, TOut>

The function to transform the value if the result is successful.

Returns

ValueTask<Result<TOut>>

A new success result with the transformed value if success; otherwise the original failure.

Type Parameters

TIn

Type of the input result value.

TOut

Type of the output result value.