Class ResultAsyncExtensions
Extension methods for async operations involving Result<T, TErr>.
Inherited Members
Namespace: RustyOptions.Async
Assembly: RustyOptions.dll
Syntax
public static class ResultAsyncExtensions
Methods
| Edit this page View SourceAndThenAsync<T1, T2, TErr>(Result<T1, TErr>, Func<T1, Task<Result<T2, TErr>>>)
Asynchronously calls thenFunc
if the result is Ok
, otherwise returns the Err
value of self
.
Declaration
public static ValueTask<Result<T2, TErr>> AndThenAsync<T1, T2, TErr>(this Result<T1, TErr> self, Func<T1, Task<Result<T2, TErr>>> thenFunc) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Result<T1, TErr> | self | The result. |
Func<T1, Task<Result<T2, TErr>>> | thenFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | The result of calling |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
AndThenAsync<T1, T2, TErr>(Result<T1, TErr>, Func<T1, ValueTask<Result<T2, TErr>>>)
Asynchronously calls thenFunc
if the result is Ok
, otherwise returns the Err
value of self
.
Declaration
public static ValueTask<Result<T2, TErr>> AndThenAsync<T1, T2, TErr>(this Result<T1, TErr> self, Func<T1, ValueTask<Result<T2, TErr>>> thenFunc) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Result<T1, TErr> | self | The result. |
Func<T1, ValueTask<Result<T2, TErr>>> | thenFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | The result of calling |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
AndThenAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, Result<T2, TErr>>)
Asynchronously calls thenFunc
if the result is Ok
, otherwise returns the Err
value of self
.
Declaration
public static ValueTask<Result<T2, TErr>> AndThenAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, Result<T2, TErr>> thenFunc) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result. |
Func<T1, Result<T2, TErr>> | thenFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | The result of calling |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
AndThenAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, Task<Result<T2, TErr>>>)
Asynchronously calls thenFunc
if the result is Ok
, otherwise returns the Err
value of self
.
Declaration
public static ValueTask<Result<T2, TErr>> AndThenAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, Task<Result<T2, TErr>>> thenFunc) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result. |
Func<T1, Task<Result<T2, TErr>>> | thenFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | The result of calling |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
AndThenAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, ValueTask<Result<T2, TErr>>>)
Asynchronously calls thenFunc
if the result is Ok
, otherwise returns the Err
value of self
.
Declaration
public static ValueTask<Result<T2, TErr>> AndThenAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, ValueTask<Result<T2, TErr>>> thenFunc) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result. |
Func<T1, ValueTask<Result<T2, TErr>>> | thenFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | The result of calling |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
AndThenAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, Result<T2, TErr>>)
Asynchronously calls thenFunc
if the result is Ok
, otherwise returns the Err
value of self
.
Declaration
public static ValueTask<Result<T2, TErr>> AndThenAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, Result<T2, TErr>> thenFunc) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result. |
Func<T1, Result<T2, TErr>> | thenFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | The result of calling |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
AndThenAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, Task<Result<T2, TErr>>>)
Asynchronously calls thenFunc
if the result is Ok
, otherwise returns the Err
value of self
.
Declaration
public static ValueTask<Result<T2, TErr>> AndThenAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, Task<Result<T2, TErr>>> thenFunc) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result. |
Func<T1, Task<Result<T2, TErr>>> | thenFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | The result of calling |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
AndThenAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, ValueTask<Result<T2, TErr>>>)
Asynchronously calls thenFunc
if the result is Ok
, otherwise returns the Err
value of self
.
Declaration
public static ValueTask<Result<T2, TErr>> AndThenAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, ValueTask<Result<T2, TErr>>> thenFunc) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result. |
Func<T1, ValueTask<Result<T2, TErr>>> | thenFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | The result of calling |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
ErrorsAsync<T, TErr>(IAsyncEnumerable<Result<T, TErr>>, CancellationToken)
Flattens an asynchronous sequence of Result<T, TErr> into a sequence containing all error values. Ok results are discarded.
Declaration
public static IAsyncEnumerable<TErr> ErrorsAsync<T, TErr>(this IAsyncEnumerable<Result<T, TErr>> self, CancellationToken ct = default) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<Result<T, TErr>> | self | The asynchronsou sequence of results. |
CancellationToken | ct | A CancellationToken that will interrupt async iteration. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TErr> | A flattened sequence of values. |
Type Parameters
Name | Description |
---|---|
T | |
TErr |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |
MapAsync<T1, T2, TErr>(Result<T1, TErr>, Func<T1, Task<T2>>)
Asynchronously maps a result by applying a function to a contained Ok
value, leaving an Err
value untouched.
Declaration
public static ValueTask<Result<T2, TErr>> MapAsync<T1, T2, TErr>(this Result<T1, TErr> self, Func<T1, Task<T2>> mapper) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Result<T1, TErr> | self | The result to map. |
Func<T1, Task<T2>> | mapper | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | A result containing the mapped value, or |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapAsync<T1, T2, TErr>(Result<T1, TErr>, Func<T1, ValueTask<T2>>)
Asynchronously maps a result by applying a function to a contained Ok
value, leaving an Err
value untouched.
Declaration
public static ValueTask<Result<T2, TErr>> MapAsync<T1, T2, TErr>(this Result<T1, TErr> self, Func<T1, ValueTask<T2>> mapper) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Result<T1, TErr> | self | The result to map. |
Func<T1, ValueTask<T2>> | mapper | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | A result containing the mapped value, or |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, Task<T2>>)
Asynchronously maps a result by applying a function to a contained Ok
value, leaving an Err
value untouched.
Declaration
public static ValueTask<Result<T2, TErr>> MapAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, Task<T2>> mapper) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result to map. |
Func<T1, Task<T2>> | mapper | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | A result containing the mapped value, or |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, ValueTask<T2>>)
Asynchronously maps a result by applying a function to a contained Ok
value, leaving an Err
value untouched.
Declaration
public static ValueTask<Result<T2, TErr>> MapAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, ValueTask<T2>> mapper) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result to map. |
Func<T1, ValueTask<T2>> | mapper | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | A result containing the mapped value, or |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, T2>)
Asynchronously maps a result by applying a function to a contained Ok
value, leaving an Err
value untouched.
Declaration
public static ValueTask<Result<T2, TErr>> MapAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, T2> mapper) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result to map. |
Func<T1, T2> | mapper | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | A result containing the mapped value, or |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, Task<T2>>)
Asynchronously maps a result by applying a function to a contained Ok
value, leaving an Err
value untouched.
Declaration
public static ValueTask<Result<T2, TErr>> MapAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, Task<T2>> mapper) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result to map. |
Func<T1, Task<T2>> | mapper | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | A result containing the mapped value, or |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, ValueTask<T2>>)
Asynchronously maps a result by applying a function to a contained Ok
value, leaving an Err
value untouched.
Declaration
public static ValueTask<Result<T2, TErr>> MapAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, ValueTask<T2>> mapper) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result to map. |
Func<T1, ValueTask<T2>> | mapper | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | A result containing the mapped value, or |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, T2>)
Asynchronously maps a result by applying a function to a contained Ok
value, leaving an Err
value untouched.
Declaration
public static ValueTask<Result<T2, TErr>> MapAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, T2> mapper) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result to map. |
Func<T1, T2> | mapper | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<Result<T2, TErr>> | A result containing the mapped value, or |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapOrElseAsync<T1, T2, TErr>(Result<T1, TErr>, Func<T1, Task<T2>>, Func<TErr, Task<T2>>)
Asynchronously maps a Result
by applying fallback function defaultFactory
to a
contained Err
value, or function mapper
to a contained Ok
value.
This function can be used to unpack a successful result while handling an error.
Declaration
public static ValueTask<T2> MapOrElseAsync<T1, T2, TErr>(this Result<T1, TErr> self, Func<T1, Task<T2>> mapper, Func<TErr, Task<T2>> defaultFactory) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Result<T1, TErr> | self | The result to map. |
Func<T1, Task<T2>> | mapper | The function that converts a contained |
Func<TErr, Task<T2>> | defaultFactory | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<T2> | The mapped value. |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapOrElseAsync<T1, T2, TErr>(Result<T1, TErr>, Func<T1, ValueTask<T2>>, Func<TErr, ValueTask<T2>>)
Asynchronously maps a Result
by applying fallback function defaultFactory
to a
contained Err
value, or function mapper
to a contained Ok
value.
This function can be used to unpack a successful result while handling an error.
Declaration
public static ValueTask<T2> MapOrElseAsync<T1, T2, TErr>(this Result<T1, TErr> self, Func<T1, ValueTask<T2>> mapper, Func<TErr, ValueTask<T2>> defaultFactory) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Result<T1, TErr> | self | The result to map. |
Func<T1, ValueTask<T2>> | mapper | The function that converts a contained |
Func<TErr, ValueTask<T2>> | defaultFactory | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<T2> | The mapped value. |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapOrElseAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, Task<T2>>, Func<TErr, Task<T2>>)
Asynchronously maps a Result
by applying fallback function defaultFactory
to a
contained Err
value, or function mapper
to a contained Ok
value.
This function can be used to unpack a successful result while handling an error.
Declaration
public static ValueTask<T2> MapOrElseAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, Task<T2>> mapper, Func<TErr, Task<T2>> defaultFactory) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result to map. |
Func<T1, Task<T2>> | mapper | The function that converts a contained |
Func<TErr, Task<T2>> | defaultFactory | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<T2> | The mapped value. |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapOrElseAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, ValueTask<T2>>, Func<TErr, ValueTask<T2>>)
Asynchronously maps a Result
by applying fallback function defaultFactory
to a
contained Err
value, or function mapper
to a contained Ok
value.
This function can be used to unpack a successful result while handling an error.
Declaration
public static ValueTask<T2> MapOrElseAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, ValueTask<T2>> mapper, Func<TErr, ValueTask<T2>> defaultFactory) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result to map. |
Func<T1, ValueTask<T2>> | mapper | The function that converts a contained |
Func<TErr, ValueTask<T2>> | defaultFactory | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<T2> | The mapped value. |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapOrElseAsync<T1, T2, TErr>(Task<Result<T1, TErr>>, Func<T1, T2>, Func<TErr, T2>)
Asynchronously maps a Result
by applying fallback function defaultFactory
to a
contained Err
value, or function mapper
to a contained Ok
value.
This function can be used to unpack a successful result while handling an error.
Declaration
public static ValueTask<T2> MapOrElseAsync<T1, T2, TErr>(this Task<Result<T1, TErr>> self, Func<T1, T2> mapper, Func<TErr, T2> defaultFactory) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T1, TErr>> | self | The result to map. |
Func<T1, T2> | mapper | The function that converts a contained |
Func<TErr, T2> | defaultFactory | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<T2> | The mapped value. |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapOrElseAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, Task<T2>>, Func<TErr, Task<T2>>)
Asynchronously maps a Result
by applying fallback function defaultFactory
to a
contained Err
value, or function mapper
to a contained Ok
value.
This function can be used to unpack a successful result while handling an error.
Declaration
public static ValueTask<T2> MapOrElseAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, Task<T2>> mapper, Func<TErr, Task<T2>> defaultFactory) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result to map. |
Func<T1, Task<T2>> | mapper | The function that converts a contained |
Func<TErr, Task<T2>> | defaultFactory | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<T2> | The mapped value. |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapOrElseAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, ValueTask<T2>>, Func<TErr, ValueTask<T2>>)
Asynchronously maps a Result
by applying fallback function defaultFactory
to a
contained Err
value, or function mapper
to a contained Ok
value.
This function can be used to unpack a successful result while handling an error.
Declaration
public static ValueTask<T2> MapOrElseAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, ValueTask<T2>> mapper, Func<TErr, ValueTask<T2>> defaultFactory) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result to map. |
Func<T1, ValueTask<T2>> | mapper | The function that converts a contained |
Func<TErr, ValueTask<T2>> | defaultFactory | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<T2> | The mapped value. |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
MapOrElseAsync<T1, T2, TErr>(ValueTask<Result<T1, TErr>>, Func<T1, T2>, Func<TErr, T2>)
Asynchronously maps a Result
by applying fallback function defaultFactory
to a
contained Err
value, or function mapper
to a contained Ok
value.
This function can be used to unpack a successful result while handling an error.
Declaration
public static ValueTask<T2> MapOrElseAsync<T1, T2, TErr>(this ValueTask<Result<T1, TErr>> self, Func<T1, T2> mapper, Func<TErr, T2> defaultFactory) where T1 : notnull where T2 : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T1, TErr>> | self | The result to map. |
Func<T1, T2> | mapper | The function that converts a contained |
Func<TErr, T2> | defaultFactory | The function that converts a contained |
Returns
Type | Description |
---|---|
ValueTask<T2> | The mapped value. |
Type Parameters
Name | Description |
---|---|
T1 | The |
T2 | The |
TErr | The |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
OrElseAsync<T, T1Err, T2Err>(Result<T, T1Err>, Func<T1Err?, Task<Result<T, T2Err>>>)
Asynchronously calls elseFunc
if the result is Err
, otherwise returns the Ok
value of self
.
Declaration
public static ValueTask<Result<T, T2Err>> OrElseAsync<T, T1Err, T2Err>(this Result<T, T1Err> self, Func<T1Err?, Task<Result<T, T2Err>>> elseFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
Result<T, T1Err> | self | The result. |
Func<T1Err, Task<Result<T, T2Err>>> | elseFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T, T2Err>> | The |
Type Parameters
Name | Description |
---|---|
T | The |
T1Err | The |
T2Err | The |
OrElseAsync<T, T1Err, T2Err>(Result<T, T1Err>, Func<T1Err?, ValueTask<Result<T, T2Err>>>)
Asynchronously calls elseFunc
if the result is Err
, otherwise returns the Ok
value of self
.
Declaration
public static ValueTask<Result<T, T2Err>> OrElseAsync<T, T1Err, T2Err>(this Result<T, T1Err> self, Func<T1Err?, ValueTask<Result<T, T2Err>>> elseFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
Result<T, T1Err> | self | The result. |
Func<T1Err, ValueTask<Result<T, T2Err>>> | elseFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T, T2Err>> | The |
Type Parameters
Name | Description |
---|---|
T | The |
T1Err | The |
T2Err | The |
OrElseAsync<T, T1Err, T2Err>(Task<Result<T, T1Err>>, Func<T1Err?, Result<T, T2Err>>)
Asynchronously calls elseFunc
if the result is Err
, otherwise returns the Ok
value of self
.
Declaration
public static ValueTask<Result<T, T2Err>> OrElseAsync<T, T1Err, T2Err>(this Task<Result<T, T1Err>> self, Func<T1Err?, Result<T, T2Err>> elseFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T, T1Err>> | self | The result. |
Func<T1Err, Result<T, T2Err>> | elseFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T, T2Err>> | The |
Type Parameters
Name | Description |
---|---|
T | The |
T1Err | The |
T2Err | The |
OrElseAsync<T, T1Err, T2Err>(Task<Result<T, T1Err>>, Func<T1Err?, Task<Result<T, T2Err>>>)
Asynchronously calls elseFunc
if the result is Err
, otherwise returns the Ok
value of self
.
Declaration
public static ValueTask<Result<T, T2Err>> OrElseAsync<T, T1Err, T2Err>(this Task<Result<T, T1Err>> self, Func<T1Err?, Task<Result<T, T2Err>>> elseFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T, T1Err>> | self | The result. |
Func<T1Err, Task<Result<T, T2Err>>> | elseFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T, T2Err>> | The |
Type Parameters
Name | Description |
---|---|
T | The |
T1Err | The |
T2Err | The |
OrElseAsync<T, T1Err, T2Err>(Task<Result<T, T1Err>>, Func<T1Err?, ValueTask<Result<T, T2Err>>>)
Asynchronously calls elseFunc
if the result is Err
, otherwise returns the Ok
value of self
.
Declaration
public static ValueTask<Result<T, T2Err>> OrElseAsync<T, T1Err, T2Err>(this Task<Result<T, T1Err>> self, Func<T1Err?, ValueTask<Result<T, T2Err>>> elseFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
Task<Result<T, T1Err>> | self | The result. |
Func<T1Err, ValueTask<Result<T, T2Err>>> | elseFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T, T2Err>> | The |
Type Parameters
Name | Description |
---|---|
T | The |
T1Err | The |
T2Err | The |
OrElseAsync<T, T1Err, T2Err>(ValueTask<Result<T, T1Err>>, Func<T1Err?, Result<T, T2Err>>)
Asynchronously calls elseFunc
if the result is Err
, otherwise returns the Ok
value of self
.
Declaration
public static ValueTask<Result<T, T2Err>> OrElseAsync<T, T1Err, T2Err>(this ValueTask<Result<T, T1Err>> self, Func<T1Err?, Result<T, T2Err>> elseFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T, T1Err>> | self | The result. |
Func<T1Err, Result<T, T2Err>> | elseFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T, T2Err>> | The |
Type Parameters
Name | Description |
---|---|
T | The |
T1Err | The |
T2Err | The |
OrElseAsync<T, T1Err, T2Err>(ValueTask<Result<T, T1Err>>, Func<T1Err?, Task<Result<T, T2Err>>>)
Asynchronously calls elseFunc
if the result is Err
, otherwise returns the Ok
value of self
.
Declaration
public static ValueTask<Result<T, T2Err>> OrElseAsync<T, T1Err, T2Err>(this ValueTask<Result<T, T1Err>> self, Func<T1Err?, Task<Result<T, T2Err>>> elseFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T, T1Err>> | self | The result. |
Func<T1Err, Task<Result<T, T2Err>>> | elseFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T, T2Err>> | The |
Type Parameters
Name | Description |
---|---|
T | The |
T1Err | The |
T2Err | The |
OrElseAsync<T, T1Err, T2Err>(ValueTask<Result<T, T1Err>>, Func<T1Err?, ValueTask<Result<T, T2Err>>>)
Asynchronously calls elseFunc
if the result is Err
, otherwise returns the Ok
value of self
.
Declaration
public static ValueTask<Result<T, T2Err>> OrElseAsync<T, T1Err, T2Err>(this ValueTask<Result<T, T1Err>> self, Func<T1Err?, ValueTask<Result<T, T2Err>>> elseFunc) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
ValueTask<Result<T, T1Err>> | self | The result. |
Func<T1Err, ValueTask<Result<T, T2Err>>> | elseFunc | The function to call with the |
Returns
Type | Description |
---|---|
ValueTask<Result<T, T2Err>> | The |
Type Parameters
Name | Description |
---|---|
T | The |
T1Err | The |
T2Err | The |
ValuesAsync<T, TErr>(IAsyncEnumerable<Result<T, TErr>>, CancellationToken)
Flattens an asynchronous sequence of Result<T, TErr> into a sequence containing all inner values. Error results are discarded.
Declaration
public static IAsyncEnumerable<T> ValuesAsync<T, TErr>(this IAsyncEnumerable<Result<T, TErr>> self, CancellationToken ct = default) where T : notnull
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<Result<T, TErr>> | self | The asynchronsous sequence of results. |
CancellationToken | ct | A CancellationToken that will interrupt async iteration. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<T> | A flattened sequence of values. |
Type Parameters
Name | Description |
---|---|
T | |
TErr |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when |