methodBind
public static Task<Result> Bind(this Task<Result> resultTask, Func<CancellationToken, Task<Result>> bind, CancellationToken cancellationToken = default)
If the `Result` is a success, invokes the async `bind` delegate with a `CancellationToken`, returning its result. If the Result is a failure, returns the failure without invoking `bind`.
- resultTask: this Task<Result>
- The task containing the source result.
- bind: Func<CancellationToken, Task<Result>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind
public static Task<Result> Bind(this Task<Result> resultTask, Func<Result> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result>
- The task containing the source result.
- bind: Func<Result>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind
public static Task<Result> Bind(this Task<Result> resultTask, Func<Task<Result>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result>
- The task containing the source result.
- bind: Func<Task<Result>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind
public static ValueTask<Result> Bind(this ValueTask<Result> resultTask, Func<CancellationToken, ValueTask<Result>> bind, CancellationToken cancellationToken = default)
If the `Result` is a success, invokes the async `bind` delegate with a `CancellationToken`, returning its result. If the Result is a failure, returns the failure without invoking `bind`.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- bind: Func<CancellationToken, ValueTask<Result>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind
public static ValueTask<Result> Bind(this ValueTask<Result> resultTask, Func<Result> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- bind: Func<Result>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind
public static ValueTask<Result> Bind(this ValueTask<Result> resultTask, Func<ValueTask<Result>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- bind: Func<ValueTask<Result>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind<T, TNext>
public static Task<Result<TNext>> Bind<T, TNext>(this Task<Result<T>> resultTask, Func<T, Result<TNext>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- bind: Func<T, Result<TNext>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<T, TNext>
public static Task<Result<TNext>> Bind<T, TNext>(this Task<Result<T>> resultTask, Func<T, Task<Result<TNext>>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- bind: Func<T, Task<Result<TNext>>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<T, TNext>
public static ValueTask<Result<TNext>> Bind<T, TNext>(this ValueTask<Result<T>> resultTask, Func<T, Result<TNext>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- bind: Func<T, Result<TNext>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<T, TNext>
public static ValueTask<Result<TNext>> Bind<T, TNext>(this ValueTask<Result<T>> resultTask, Func<T, ValueTask<Result<TNext>>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- bind: Func<T, ValueTask<Result<TNext>>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<T>
public static Task<Result> Bind<T>(this Task<Result<T>> resultTask, Func<T, Result> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- bind: Func<T, Result>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind<T>
public static Task<Result> Bind<T>(this Task<Result<T>> resultTask, Func<T, Task<Result>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- bind: Func<T, Task<Result>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind<T>
public static ValueTask<Result> Bind<T>(this ValueTask<Result<T>> resultTask, Func<T, Result> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- bind: Func<T, Result>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind<T>
public static ValueTask<Result> Bind<T>(this ValueTask<Result<T>> resultTask, Func<T, ValueTask<Result>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- bind: Func<T, ValueTask<Result>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind<TNext>
public static Task<Result<TNext>> Bind<TNext>(this Task<Result> resultTask, Func<CancellationToken, Task<Result<TNext>>> bind, CancellationToken cancellationToken = default)
If the `Result` is a success, invokes the async `bind` delegate with a `CancellationToken`, returning a typed Result. If the Result is a failure, returns the failure without invoking `bind`.
- resultTask: this Task<Result>
- The task containing the source result.
- bind: Func<CancellationToken, Task<Result<TNext>>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TNext>
public static Task<Result<TNext>> Bind<TNext>(this Task<Result> resultTask, Func<Result<TNext>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result>
- The task containing the source result.
- bind: Func<Result<TNext>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TNext>
public static Task<Result<TNext>> Bind<TNext>(this Task<Result> resultTask, Func<Task<Result<TNext>>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result>
- The task containing the source result.
- bind: Func<Task<Result<TNext>>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TNext>
public static ValueTask<Result<TNext>> Bind<TNext>(this ValueTask<Result> resultTask, Func<CancellationToken, ValueTask<Result<TNext>>> bind, CancellationToken cancellationToken = default)
If the `Result` is a success, invokes the async `bind` delegate with a `CancellationToken`, returning a typed Result. If the Result is a failure, returns the failure without invoking `bind`.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- bind: Func<CancellationToken, ValueTask<Result<TNext>>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TNext>
public static ValueTask<Result<TNext>> Bind<TNext>(this ValueTask<Result> resultTask, Func<Result<TNext>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- bind: Func<Result<TNext>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TNext>
public static ValueTask<Result<TNext>> Bind<TNext>(this ValueTask<Result> resultTask, Func<ValueTask<Result<TNext>>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- bind: Func<ValueTask<Result<TNext>>>
- The binding function applied to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TState, T, TNext>
public static Task<Result<TNext>> Bind<TState, T, TNext>(this Task<Result<T>> resultTask, TState state, Func<TState, T, Result<TNext>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- bind: Func<TState, T, Result<TNext>>
- The binding function applied to the state and result to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TState, T, TNext>
public static ValueTask<Result<TNext>> Bind<TState, T, TNext>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, T, Result<TNext>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- bind: Func<TState, T, Result<TNext>>
- The binding function applied to the state and result to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TState, T>
public static Task<Result> Bind<TState, T>(this Task<Result<T>> resultTask, TState state, Func<TState, T, Result> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- bind: Func<TState, T, Result>
- The binding function applied to the state and result to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind<TState, T>
public static ValueTask<Result> Bind<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, T, Result> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- bind: Func<TState, T, Result>
- The binding function applied to the state and result to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind<TState, TNext>
public static Task<Result<TNext>> Bind<TState, TNext>(this Task<Result> resultTask, TState state, Func<TState, Result<TNext>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- bind: Func<TState, Result<TNext>>
- The binding function applied to the state and result to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TState, TNext>
public static ValueTask<Result<TNext>> Bind<TState, TNext>(this ValueTask<Result> resultTask, TState state, Func<TState, Result<TNext>> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- bind: Func<TState, Result<TNext>>
- The binding function applied to the state and result to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the bound `Result<TNext>` on success, or the original failure.
methodBind<TState>
public static Task<Result> Bind<TState>(this Task<Result> resultTask, TState state, Func<TState, Result> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- bind: Func<TState, Result>
- The binding function applied to the state and result to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the result of the binding operation.
methodBind<TState>
public static ValueTask<Result> Bind<TState>(this ValueTask<Result> resultTask, TState state, Func<TState, Result> bind, CancellationToken cancellationToken = default)
Chains an operation returning a new result on success, short-circuiting on failure.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- bind: Func<TState, Result>
- The binding function applied to the state and result to produce the next result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the result of the binding operation.
methodEnsure
public static Task<Result> Ensure(this Task<Result> resultTask, Func<bool> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this Task<Result>
- The task containing the source result.
- predicate: Func<bool>
- The condition to assert against the successful result.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure
public static ValueTask<Result> Ensure(this ValueTask<Result> resultTask, Func<bool> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- predicate: Func<bool>
- The condition to assert against the successful result.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<T>
public static Task<Result<T>> Ensure<T>(this Task<Result<T>> resultTask, Func<T, Task<bool>> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- predicate: Func<T, Task<bool>>
- The condition to assert against the success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<T>
public static Task<Result<T>> Ensure<T>(this Task<Result<T>> resultTask, Func<T, bool> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- predicate: Func<T, bool>
- The condition to assert against the success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<T>
public static ValueTask<Result<T>> Ensure<T>(this ValueTask<Result<T>> resultTask, Func<T, ValueTask<bool>> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- predicate: Func<T, ValueTask<bool>>
- The condition to assert against the success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<T>
public static ValueTask<Result<T>> Ensure<T>(this ValueTask<Result<T>> resultTask, Func<T, bool> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- predicate: Func<T, bool>
- The condition to assert against the success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<TState, T>
public static Task<Result<T>> Ensure<TState, T>(this Task<Result<T>> resultTask, TState state, Func<TState, T, Task<bool>> predicate, Error error, CancellationToken cancellationToken = default)
Applies an async predicate with captured `TState` to the success value of a `Task<TResult>` wrapping a `Result<T>`, avoiding closure allocations.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- predicate: Func<TState, T, Task<bool>>
- The condition to assert against the state and success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<TState, T>
public static Task<Result<T>> Ensure<TState, T>(this Task<Result<T>> resultTask, TState state, Func<TState, T, bool> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- predicate: Func<TState, T, bool>
- The condition to assert against the state and success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<TState, T>
public static ValueTask<Result<T>> Ensure<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, T, ValueTask<bool>> predicate, Error error, CancellationToken cancellationToken = default)
Applies an async predicate with captured `TState` to the success value of a `ValueTask<TResult>` wrapping a `Result<T>`, avoiding closure allocations.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- predicate: Func<TState, T, ValueTask<bool>>
- The condition to assert against the state and success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<TState, T>
public static ValueTask<Result<T>> Ensure<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, T, bool> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- predicate: Func<TState, T, bool>
- The condition to assert against the state and success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<TState>
public static Task<Result> Ensure<TState>(this Task<Result> resultTask, TState state, Func<TState, bool> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- predicate: Func<TState, bool>
- The condition to assert against the state and success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodEnsure<TState>
public static ValueTask<Result> Ensure<TState>(this ValueTask<Result> resultTask, TState state, Func<TState, bool> predicate, Error error, CancellationToken cancellationToken = default)
Asserts a predicate against the asynchronous result, converting to a failure if the predicate evaluates to `false`.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- predicate: Func<TState, bool>
- The condition to assert against the state and success value.
- error: Error
- The error to return if the predicate evaluates to `false`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result if the predicate is satisfied, or a failure.
methodExecute
public static Task Execute(this Task<Result> resultTask, Action onSuccess, Action<Error> onFailure, CancellationToken cancellationToken = default)
Executes an action based on whether the asynchronous result succeeded or failed.
- resultTask: this Task<Result>
- The task containing the source result.
- onSuccess: Action
- The action executed when the result is successful.
- onFailure: Action<Error>
- The action executed when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation.
methodExecute
public static ValueTask Execute(this ValueTask<Result> resultTask, Action onSuccess, Action<Error> onFailure, CancellationToken cancellationToken = default)
Executes an action based on whether the asynchronous result succeeded or failed.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- onSuccess: Action
- The action executed when the result is successful.
- onFailure: Action<Error>
- The action executed when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation.
methodExecute<T>
public static Task Execute<T>(this Task<Result<T>> resultTask, Action<T> onSuccess, Action<Error> onFailure, CancellationToken cancellationToken = default)
Executes an action based on whether the asynchronous result succeeded or failed.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- onSuccess: Action<T>
- The action executed when the result is successful.
- onFailure: Action<Error>
- The action executed when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation.
methodExecute<T>
public static ValueTask Execute<T>(this ValueTask<Result<T>> resultTask, Action<T> onSuccess, Action<Error> onFailure, CancellationToken cancellationToken = default)
Executes an action based on whether the asynchronous result succeeded or failed.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- onSuccess: Action<T>
- The action executed when the result is successful.
- onFailure: Action<Error>
- The action executed when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation.
methodExecute<TState, T>
public static Task Execute<TState, T>(this Task<Result<T>> resultTask, TState state, Action<TState, T> onSuccess, Action<TState, Error> onFailure, CancellationToken cancellationToken = default)
Executes an action based on whether the asynchronous result succeeded or failed.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Action<TState, T>
- The action executed with the state and success value when the result is successful.
- onFailure: Action<TState, Error>
- The action executed with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation.
methodExecute<TState, T>
public static ValueTask Execute<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Action<TState, T> onSuccess, Action<TState, Error> onFailure, CancellationToken cancellationToken = default)
Executes an action based on whether the asynchronous result succeeded or failed.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Action<TState, T>
- The action executed with the state and success value when the result is successful.
- onFailure: Action<TState, Error>
- The action executed with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation.
methodExecute<TState>
public static Task Execute<TState>(this Task<Result> resultTask, TState state, Action<TState> onSuccess, Action<TState, Error> onFailure, CancellationToken cancellationToken = default)
Executes an action based on whether the asynchronous result succeeded or failed.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Action<TState>
- The action executed with the state and success value when the result is successful.
- onFailure: Action<TState, Error>
- The action executed with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation.
methodExecute<TState>
public static ValueTask Execute<TState>(this ValueTask<Result> resultTask, TState state, Action<TState> onSuccess, Action<TState, Error> onFailure, CancellationToken cancellationToken = default)
Executes an action based on whether the asynchronous result succeeded or failed.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Action<TState>
- The action executed with the state and success value when the result is successful.
- onFailure: Action<TState, Error>
- The action executed with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation.
methodInspect
public static Task<Result> Inspect(this Task<Result> resultTask, Action<Result> action, CancellationToken cancellationToken = default)
Executes an inspection action on the asynchronous result regardless of its success or failure state.
- resultTask: this Task<Result>
- The task containing the source result.
- action: Action<Result>
- The side-effect action to execute with the evaluated result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodInspect
public static ValueTask<Result> Inspect(this ValueTask<Result> resultTask, Action<Result> action, CancellationToken cancellationToken = default)
Executes an inspection action on the asynchronous result regardless of its success or failure state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- action: Action<Result>
- The side-effect action to execute with the evaluated result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodInspect<T>
public static Task<Result<T>> Inspect<T>(this Task<Result<T>> resultTask, Action<Result<T>> action, CancellationToken cancellationToken = default)
Executes an inspection action on the asynchronous result regardless of its success or failure state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- action: Action<Result<T>>
- The side-effect action to execute with the evaluated result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodInspect<T>
public static ValueTask<Result<T>> Inspect<T>(this ValueTask<Result<T>> resultTask, Action<Result<T>> action, CancellationToken cancellationToken = default)
Executes an inspection action on the asynchronous result regardless of its success or failure state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- action: Action<Result<T>>
- The side-effect action to execute with the evaluated result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodInspect<TState, T>
public static Task<Result<T>> Inspect<TState, T>(this Task<Result<T>> resultTask, TState state, Action<TState, Result<T>> action, CancellationToken cancellationToken = default)
Executes an inspection action on the asynchronous result regardless of its success or failure state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- action: Action<TState, Result<T>>
- The side-effect action to execute with the evaluated result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodInspect<TState, T>
public static ValueTask<Result<T>> Inspect<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Action<TState, Result<T>> action, CancellationToken cancellationToken = default)
Executes an inspection action on the asynchronous result regardless of its success or failure state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- action: Action<TState, Result<T>>
- The side-effect action to execute with the evaluated result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodInspect<TState>
public static Task<Result> Inspect<TState>(this Task<Result> resultTask, TState state, Action<TState, Result> action, CancellationToken cancellationToken = default)
Executes an inspection action on the asynchronous result regardless of its success or failure state.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- action: Action<TState, Result>
- The side-effect action to execute with the evaluated result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodInspect<TState>
public static ValueTask<Result> Inspect<TState>(this ValueTask<Result> resultTask, TState state, Action<TState, Result> action, CancellationToken cancellationToken = default)
Executes an inspection action on the asynchronous result regardless of its success or failure state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- action: Action<TState, Result>
- The side-effect action to execute with the evaluated result.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodMap<T, TNext>
public static Task<Result<TNext>> Map<T, TNext>(this Task<Result<T>> resultTask, Func<T, TNext> mapper, CancellationToken cancellationToken = default)
Transforms the value of the asynchronous result using the specified mapping function on success.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- mapper: Func<T, TNext>
- The mapping function applied to the success value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<T, TNext>
public static Task<Result<TNext>> Map<T, TNext>(this Task<Result<T>> resultTask, Func<T, Task<TNext>> mapper, CancellationToken cancellationToken = default)
Transforms the value of the asynchronous result using the specified mapping function on success.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- mapper: Func<T, Task<TNext>>
- The mapping function applied to the success value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<T, TNext>
public static ValueTask<Result<TNext>> Map<T, TNext>(this ValueTask<Result<T>> resultTask, Func<T, TNext> mapper, CancellationToken cancellationToken = default)
Transforms the value of the asynchronous result using the specified mapping function on success.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- mapper: Func<T, TNext>
- The mapping function applied to the success value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<T, TNext>
public static ValueTask<Result<TNext>> Map<T, TNext>(this ValueTask<Result<T>> resultTask, Func<T, ValueTask<TNext>> mapper, CancellationToken cancellationToken = default)
Transforms the value of the asynchronous result using the specified mapping function on success.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- mapper: Func<T, ValueTask<TNext>>
- The mapping function applied to the success value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TNext>
public static Task<Result<TNext>> Map<TNext>(this Task<Result> resultTask, Func<CancellationToken, Task<TNext>> mapper, CancellationToken cancellationToken = default)
Projects a successful `Result` into a `Result<TNext>` by executing an async `mapper` that receives a `CancellationToken`. If the Result is a failure, returns a failure without invoking `mapper`.
- resultTask: this Task<Result>
- The task containing the source result.
- mapper: Func<CancellationToken, Task<TNext>>
- The mapping function producing a new value on success.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TNext>
public static Task<Result<TNext>> Map<TNext>(this Task<Result> resultTask, Func<TNext> mapper, CancellationToken cancellationToken = default)
Projects a successful `Result` into a `Result<TNext>` by executing `mapper` on success. If the Result is a failure, returns a failure without invoking `mapper`.
- resultTask: this Task<Result>
- The task containing the source result.
- mapper: Func<TNext>
- The mapping function producing a new value on success.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TNext>
public static ValueTask<Result<TNext>> Map<TNext>(this ValueTask<Result> resultTask, Func<CancellationToken, ValueTask<TNext>> mapper, CancellationToken cancellationToken = default)
Projects a successful `Result` into a `Result<TNext>` by executing an async `mapper` that receives a `CancellationToken`. If the Result is a failure, returns a failure without invoking `mapper`.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- mapper: Func<CancellationToken, ValueTask<TNext>>
- The mapping function producing a new value on success.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TNext>
public static ValueTask<Result<TNext>> Map<TNext>(this ValueTask<Result> resultTask, Func<TNext> mapper, CancellationToken cancellationToken = default)
Projects a successful `Result` into a `Result<TNext>` by executing `mapper` on success. If the Result is a failure, returns a failure without invoking `mapper`.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- mapper: Func<TNext>
- The mapping function producing a new value on success.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TState, T, TNext>
public static Task<Result<TNext>> Map<TState, T, TNext>(this Task<Result<T>> resultTask, TState state, Func<TState, T, TNext> mapper, CancellationToken cancellationToken = default)
Transforms the value of the asynchronous result using the specified mapping function on success.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, T, TNext>
- The mapping function applied to the state and success value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TState, T, TNext>
public static Task<Result<TNext>> Map<TState, T, TNext>(this Task<Result<T>> resultTask, TState state, Func<TState, T, Task<TNext>> mapper, CancellationToken cancellationToken = default)
Maps the success value of a `Task<TResult>` wrapping a `Result<T>` using an async mapper with captured `TState` to avoid closure allocations.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, T, Task<TNext>>
- The mapping function applied to the state and success value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TState, T, TNext>
public static ValueTask<Result<TNext>> Map<TState, T, TNext>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, T, TNext> mapper, CancellationToken cancellationToken = default)
Transforms the value of the asynchronous result using the specified mapping function on success.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, T, TNext>
- The mapping function applied to the state and success value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TState, T, TNext>
public static ValueTask<Result<TNext>> Map<TState, T, TNext>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, T, ValueTask<TNext>> mapper, CancellationToken cancellationToken = default)
Maps the success value of a `ValueTask<TResult>` wrapping a `Result<T>` using an async mapper with captured `TState` to avoid closure allocations.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, T, ValueTask<TNext>>
- The mapping function applied to the state and success value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TState, TNext>
public static Task<Result<TNext>> Map<TState, TNext>(this Task<Result> resultTask, TState state, Func<TState, TNext> mapper, CancellationToken cancellationToken = default)
Projects a successful `Result` into a `Result<TNext>` using a state argument to avoid closure allocations.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, TNext>
- The mapping function applied to the state to produce a new value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMap<TState, TNext>
public static ValueTask<Result<TNext>> Map<TState, TNext>(this ValueTask<Result> resultTask, TState state, Func<TState, TNext> mapper, CancellationToken cancellationToken = default)
Projects a successful `Result` into a `Result<TNext>` using a state argument to avoid closure allocations.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, TNext>
- The mapping function applied to the state to produce a new value.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a `Result<TNext>` with the mapped value on success, or the original failure.
methodMapError
public static Task<Result> MapError(this Task<Result> resultTask, Func<Error, Error> mapper, CancellationToken cancellationToken = default)
Transforms the inner error of the asynchronous result if in a failure state.
- resultTask: this Task<Result>
- The task containing the source result.
- mapper: Func<Error, Error>
- The mapping function applied to the error on failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result on success, or a failure with the transformed error.
methodMapError
public static ValueTask<Result> MapError(this ValueTask<Result> resultTask, Func<Error, Error> mapper, CancellationToken cancellationToken = default)
Transforms the inner error of the asynchronous result if in a failure state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- mapper: Func<Error, Error>
- The mapping function applied to the error on failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result on success, or a failure with the transformed error.
methodMapError<T>
public static Task<Result<T>> MapError<T>(this Task<Result<T>> resultTask, Func<Error, Error> mapper, CancellationToken cancellationToken = default)
Transforms the inner error of the asynchronous result if in a failure state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- mapper: Func<Error, Error>
- The mapping function applied to the error on failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result on success, or a failure with the transformed error.
methodMapError<T>
public static ValueTask<Result<T>> MapError<T>(this ValueTask<Result<T>> resultTask, Func<Error, Error> mapper, CancellationToken cancellationToken = default)
Transforms the inner error of the asynchronous result if in a failure state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- mapper: Func<Error, Error>
- The mapping function applied to the error on failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result on success, or a failure with the transformed error.
methodMapError<TState, T>
public static Task<Result<T>> MapError<TState, T>(this Task<Result<T>> resultTask, TState state, Func<TState, Error, Error> mapper, CancellationToken cancellationToken = default)
Transforms the inner error of the asynchronous result if in a failure state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, Error, Error>
- The mapping function applied to the state and error on failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result on success, or a failure with the transformed error.
methodMapError<TState, T>
public static ValueTask<Result<T>> MapError<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, Error, Error> mapper, CancellationToken cancellationToken = default)
Transforms the inner error of the asynchronous result if in a failure state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, Error, Error>
- The mapping function applied to the state and error on failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result on success, or a failure with the transformed error.
methodMapError<TState>
public static Task<Result> MapError<TState>(this Task<Result> resultTask, TState state, Func<TState, Error, Error> mapper, CancellationToken cancellationToken = default)
Transforms the inner error of the asynchronous result if in a failure state.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, Error, Error>
- The mapping function applied to the state and error on failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result on success, or a failure with the transformed error.
methodMapError<TState>
public static ValueTask<Result> MapError<TState>(this ValueTask<Result> resultTask, TState state, Func<TState, Error, Error> mapper, CancellationToken cancellationToken = default)
Transforms the inner error of the asynchronous result if in a failure state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- mapper: Func<TState, Error, Error>
- The mapping function applied to the state and error on failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result on success, or a failure with the transformed error.
methodMapFailure<T, TOut>
public static Task<TOut> MapFailure<T, TOut>(this Task<Result<T>> resultTask, Func<Error, TOut> onFailure, TOut successDefault, CancellationToken cancellationToken = default)
Maps a failure error into `TOut` using `onFailure`, or returns `successDefault` when the result is successful. Async overload for `Task<Result<T>>` pipelines.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- onFailure: Func<Error, TOut>
- The function applied to the error to produce a fallback value on failure.
- successDefault: TOut
- The default value to return when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the mapped failure value, or the default value on success.
methodMapFailure<T, TOut>
public static ValueTask<TOut> MapFailure<T, TOut>(this ValueTask<Result<T>> resultTask, Func<Error, TOut> onFailure, TOut successDefault, CancellationToken cancellationToken = default)
Maps a failure error into `TOut` using `onFailure`, or returns `successDefault` when the result is successful. Async overload for `ValueTask<Result<T>>` pipelines.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- onFailure: Func<Error, TOut>
- The function applied to the error to produce a fallback value on failure.
- successDefault: TOut
- The default value to return when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the mapped failure value, or the default value on success.
methodMapFailure<TOut>
public static Task<TOut> MapFailure<TOut>(this Task<Result> resultTask, Func<Error, TOut> onFailure, TOut successDefault, CancellationToken cancellationToken = default)
Maps a failure error into `TOut` using `onFailure`, or returns `successDefault` when the result is successful. Async overload for `Task<Result>` pipelines.
- resultTask: this Task<Result>
- The task containing the source result.
- onFailure: Func<Error, TOut>
- The function applied to the error to produce a fallback value on failure.
- successDefault: TOut
- The default value to return when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the mapped failure value, or the default value on success.
methodMapFailure<TOut>
public static ValueTask<TOut> MapFailure<TOut>(this ValueTask<Result> resultTask, Func<Error, TOut> onFailure, TOut successDefault, CancellationToken cancellationToken = default)
Maps a failure error into `TOut` using `onFailure`, or returns `successDefault` when the result is successful. Async overload for `ValueTask<Result>` pipelines.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- onFailure: Func<Error, TOut>
- The function applied to the error to produce a fallback value on failure.
- successDefault: TOut
- The default value to return when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the mapped failure value, or the default value on success.
methodMapFailure<TState, T, TOut>
public static Task<TOut> MapFailure<TState, T, TOut>(this Task<Result<T>> resultTask, TState state, Func<TState, Error, TOut> onFailure, TOut successDefault, CancellationToken cancellationToken = default)
Maps a failure error into `TOut` using captured state to avoid closure allocations. Async overload for `Task<Result<T>>` pipelines.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onFailure: Func<TState, Error, TOut>
- The function applied to the state and error to produce a fallback value on failure.
- successDefault: TOut
- The default value to return when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the mapped failure value, or the default value on success.
methodMapFailure<TState, T, TOut>
public static ValueTask<TOut> MapFailure<TState, T, TOut>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, Error, TOut> onFailure, TOut successDefault, CancellationToken cancellationToken = default)
Maps a failure error into `TOut` using captured state to avoid closure allocations. Async overload for `ValueTask<Result<T>>` pipelines.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onFailure: Func<TState, Error, TOut>
- The function applied to the state and error to produce a fallback value on failure.
- successDefault: TOut
- The default value to return when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the mapped failure value, or the default value on success.
methodMapFailure<TState, TOut>
public static Task<TOut> MapFailure<TState, TOut>(this Task<Result> resultTask, TState state, Func<TState, Error, TOut> onFailure, TOut successDefault, CancellationToken cancellationToken = default)
Maps a failure error into `TOut` using captured state to avoid closure allocations. Async overload for `Task<Result>` pipelines.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onFailure: Func<TState, Error, TOut>
- The function applied to the state and error to produce a fallback value on failure.
- successDefault: TOut
- The default value to return when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the mapped failure value, or the default value on success.
methodMapFailure<TState, TOut>
public static ValueTask<TOut> MapFailure<TState, TOut>(this ValueTask<Result> resultTask, TState state, Func<TState, Error, TOut> onFailure, TOut successDefault, CancellationToken cancellationToken = default)
Maps a failure error into `TOut` using captured state to avoid closure allocations. Async overload for `ValueTask<Result>` pipelines.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onFailure: Func<TState, Error, TOut>
- The function applied to the state and error to produce a fallback value on failure.
- successDefault: TOut
- The default value to return when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the mapped failure value, or the default value on success.
methodMatch<T, TOut>
public static Task<TOut> Match<T, TOut>(this Task<Result<T>> resultTask, Func<T, TOut> onSuccess, Func<Error, TOut> onFailure)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- onSuccess: Func<T, TOut>
- The function invoked when the result is successful.
- onFailure: Func<Error, TOut>
- The function invoked when the result is a failure.
Retorna: A task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<T, TOut>
public static Task<TOut> Match<T, TOut>(this Task<Result<T>> resultTask, Func<T, TOut> onSuccess, Func<Error, TOut> onFailure, CancellationToken cancellationToken)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- onSuccess: Func<T, TOut>
- The function invoked when the result is successful.
- onFailure: Func<Error, TOut>
- The function invoked when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<T, TOut>
public static ValueTask<TOut> Match<T, TOut>(this ValueTask<Result<T>> resultTask, Func<T, TOut> onSuccess, Func<Error, TOut> onFailure)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- onSuccess: Func<T, TOut>
- The function invoked when the result is successful.
- onFailure: Func<Error, TOut>
- The function invoked when the result is a failure.
Retorna: A value task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<T, TOut>
public static ValueTask<TOut> Match<T, TOut>(this ValueTask<Result<T>> resultTask, Func<T, TOut> onSuccess, Func<Error, TOut> onFailure, CancellationToken cancellationToken)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- onSuccess: Func<T, TOut>
- The function invoked when the result is successful.
- onFailure: Func<Error, TOut>
- The function invoked when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TOut>
public static Task<TOut> Match<TOut>(this Task<Result> resultTask, Func<TOut> onSuccess, Func<Error, TOut> onFailure)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this Task<Result>
- The task containing the source result.
- onSuccess: Func<TOut>
- The function invoked when the result is successful.
- onFailure: Func<Error, TOut>
- The function invoked when the result is a failure.
Retorna: A task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TOut>
public static Task<TOut> Match<TOut>(this Task<Result> resultTask, Func<TOut> onSuccess, Func<Error, TOut> onFailure, CancellationToken cancellationToken)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this Task<Result>
- The task containing the source result.
- onSuccess: Func<TOut>
- The function invoked when the result is successful.
- onFailure: Func<Error, TOut>
- The function invoked when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TOut>
public static ValueTask<TOut> Match<TOut>(this ValueTask<Result> resultTask, Func<TOut> onSuccess, Func<Error, TOut> onFailure)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- onSuccess: Func<TOut>
- The function invoked when the result is successful.
- onFailure: Func<Error, TOut>
- The function invoked when the result is a failure.
Retorna: A value task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TOut>
public static ValueTask<TOut> Match<TOut>(this ValueTask<Result> resultTask, Func<TOut> onSuccess, Func<Error, TOut> onFailure, CancellationToken cancellationToken)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- onSuccess: Func<TOut>
- The function invoked when the result is successful.
- onFailure: Func<Error, TOut>
- The function invoked when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TState, T, TOut>
public static Task<TOut> Match<TState, T, TOut>(this Task<Result<T>> resultTask, TState state, Func<TState, T, TOut> onSuccess, Func<TState, Error, TOut> onFailure)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Func<TState, T, TOut>
- The function invoked with the state and success value when the result is successful.
- onFailure: Func<TState, Error, TOut>
- The function invoked with the state and error when the result is a failure.
Retorna: A task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TState, T, TOut>
public static Task<TOut> Match<TState, T, TOut>(this Task<Result<T>> resultTask, TState state, Func<TState, T, TOut> onSuccess, Func<TState, Error, TOut> onFailure, CancellationToken cancellationToken)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Func<TState, T, TOut>
- The function invoked with the state and success value when the result is successful.
- onFailure: Func<TState, Error, TOut>
- The function invoked with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TState, T, TOut>
public static ValueTask<TOut> Match<TState, T, TOut>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, T, TOut> onSuccess, Func<TState, Error, TOut> onFailure)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Func<TState, T, TOut>
- The function invoked with the state and success value when the result is successful.
- onFailure: Func<TState, Error, TOut>
- The function invoked with the state and error when the result is a failure.
Retorna: A value task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TState, T, TOut>
public static ValueTask<TOut> Match<TState, T, TOut>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, T, TOut> onSuccess, Func<TState, Error, TOut> onFailure, CancellationToken cancellationToken)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Func<TState, T, TOut>
- The function invoked with the state and success value when the result is successful.
- onFailure: Func<TState, Error, TOut>
- The function invoked with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TState, TOut>
public static Task<TOut> Match<TState, TOut>(this Task<Result> resultTask, TState state, Func<TState, TOut> onSuccess, Func<TState, Error, TOut> onFailure)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Func<TState, TOut>
- The function invoked with the state and success value when the result is successful.
- onFailure: Func<TState, Error, TOut>
- The function invoked with the state and error when the result is a failure.
Retorna: A task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TState, TOut>
public static Task<TOut> Match<TState, TOut>(this Task<Result> resultTask, TState state, Func<TState, TOut> onSuccess, Func<TState, Error, TOut> onFailure, CancellationToken cancellationToken)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Func<TState, TOut>
- The function invoked with the state and success value when the result is successful.
- onFailure: Func<TState, Error, TOut>
- The function invoked with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TState, TOut>
public static ValueTask<TOut> Match<TState, TOut>(this ValueTask<Result> resultTask, TState state, Func<TState, TOut> onSuccess, Func<TState, Error, TOut> onFailure)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Func<TState, TOut>
- The function invoked with the state and success value when the result is successful.
- onFailure: Func<TState, Error, TOut>
- The function invoked with the state and error when the result is a failure.
Retorna: A value task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodMatch<TState, TOut>
public static ValueTask<TOut> Match<TState, TOut>(this ValueTask<Result> resultTask, TState state, Func<TState, TOut> onSuccess, Func<TState, Error, TOut> onFailure, CancellationToken cancellationToken)
Matches the asynchronous result, executing the appropriate projection function based on the outcome.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Func<TState, TOut>
- The function invoked with the state and success value when the result is successful.
- onFailure: Func<TState, Error, TOut>
- The function invoked with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the value produced by the invoked branch.
methodRecover
public static Task<Result> Recover(this Task<Result> resultTask, Func<Error, Result> recovery, CancellationToken cancellationToken = default)
If the `Result` is a failure, invokes `recovery` to attempt a corrective result. If the Result is a success, returns it unchanged.
- resultTask: this Task<Result>
- The task containing the source result.
- recovery: Func<Error, Result>
- The recovery function producing a fallback from the error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a successful result, or the recovered result on failure.
methodRecover
public static Task<Result> Recover(this Task<Result> resultTask, Func<Error, Task<Result>> recovery, CancellationToken cancellationToken = default)
If the `Result` is a failure, invokes the async `recovery` delegate to attempt a corrective result.
- resultTask: this Task<Result>
- The task containing the source result.
- recovery: Func<Error, Task<Result>>
- The recovery function producing a fallback from the error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a successful result, or the recovered result on failure.
methodRecover
public static ValueTask<Result> Recover(this ValueTask<Result> resultTask, Func<Error, Result> recovery, CancellationToken cancellationToken = default)
If the `Result` is a failure, invokes `recovery` to attempt a corrective result. If the Result is a success, returns it unchanged.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- recovery: Func<Error, Result>
- The recovery function producing a fallback from the error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a successful result, or the recovered result on failure.
methodRecover
public static ValueTask<Result> Recover(this ValueTask<Result> resultTask, Func<Error, ValueTask<Result>> recovery, CancellationToken cancellationToken = default)
If the `Result` is a failure, invokes the async `recovery` delegate to attempt a corrective result.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- recovery: Func<Error, ValueTask<Result>>
- The recovery function producing a fallback from the error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a successful result, or the recovered result on failure.
methodRecover<T>
public static Task<Result<T>> Recover<T>(this Task<Result<T>> resultTask, Func<Error, Result<T>> recovery, CancellationToken cancellationToken = default)
Intercepts a failure in the asynchronous result and returns an alternative fallback value or computation.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- recovery: Func<Error, Result<T>>
- The recovery function producing a fallback from the error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result on success, or the recovered result on failure.
methodRecover<T>
public static Task<Result<T>> Recover<T>(this Task<Result<T>> resultTask, Func<Error, Task<Result<T>>> recovery, CancellationToken cancellationToken = default)
Intercepts a failure in the asynchronous result and returns an alternative fallback value or computation.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- recovery: Func<Error, Task<Result<T>>>
- The recovery function producing a fallback from the error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result on success, or the recovered result on failure.
methodRecover<T>
public static ValueTask<Result<T>> Recover<T>(this ValueTask<Result<T>> resultTask, Func<Error, Result<T>> recovery, CancellationToken cancellationToken = default)
Intercepts a failure in the asynchronous result and returns an alternative fallback value or computation.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- recovery: Func<Error, Result<T>>
- The recovery function producing a fallback from the error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result on success, or the recovered result on failure.
methodRecover<T>
public static ValueTask<Result<T>> Recover<T>(this ValueTask<Result<T>> resultTask, Func<Error, ValueTask<Result<T>>> recovery, CancellationToken cancellationToken = default)
Intercepts a failure in the asynchronous result and returns an alternative fallback value or computation.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- recovery: Func<Error, ValueTask<Result<T>>>
- The recovery function producing a fallback from the error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result on success, or the recovered result on failure.
methodRecover<TState, T>
public static Task<Result<T>> Recover<TState, T>(this Task<Result<T>> resultTask, TState state, Func<TState, Error, Result<T>> recovery, CancellationToken cancellationToken = default)
Intercepts a failure in the asynchronous result and returns an alternative fallback value or computation.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- recovery: Func<TState, Error, Result<T>>
- The recovery function producing a fallback from the state and error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result on success, or the recovered result on failure.
methodRecover<TState, T>
public static Task<Result<T>> Recover<TState, T>(this Task<Result<T>> resultTask, TState state, Func<TState, Error, Task<Result<T>>> recovery, CancellationToken cancellationToken = default)
Attempts to recover from a failure using an async recovery function with captured `TState`, avoiding closure allocations.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- recovery: Func<TState, Error, Task<Result<T>>>
- The recovery function producing a fallback from the state and error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result on success, or the recovered result on failure.
methodRecover<TState, T>
public static ValueTask<Result<T>> Recover<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, Error, Result<T>> recovery, CancellationToken cancellationToken = default)
Intercepts a failure in the asynchronous result and returns an alternative fallback value or computation.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- recovery: Func<TState, Error, Result<T>>
- The recovery function producing a fallback from the state and error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result on success, or the recovered result on failure.
methodRecover<TState, T>
public static ValueTask<Result<T>> Recover<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Func<TState, Error, ValueTask<Result<T>>> recovery, CancellationToken cancellationToken = default)
Attempts to recover from a failure using an async recovery function with captured `TState`, avoiding closure allocations.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- recovery: Func<TState, Error, ValueTask<Result<T>>>
- The recovery function producing a fallback from the state and error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result on success, or the recovered result on failure.
methodRecover<TState>
public static Task<Result> Recover<TState>(this Task<Result> resultTask, TState state, Func<TState, Error, Result> recovery, CancellationToken cancellationToken = default)
If the `Result` is a failure, invokes `recovery` with captured state to attempt a corrective result.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- recovery: Func<TState, Error, Result>
- The recovery function producing a fallback from the state and error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains a successful result, or the recovered result on failure.
methodRecover<TState>
public static ValueTask<Result> Recover<TState>(this ValueTask<Result> resultTask, TState state, Func<TState, Error, Result> recovery, CancellationToken cancellationToken = default)
If the `Result` is a failure, invokes `recovery` with state to attempt a corrective result.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- recovery: Func<TState, Error, Result>
- The recovery function producing a fallback from the state and error.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains a successful result, or the recovered result on failure.
methodTapOnFailure
public static Task<Result> TapOnFailure(this Task<Result> resultTask, Action<Error> onFailure, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this Task<Result>
- The task containing the source result.
- onFailure: Action<Error>
- The action executed when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure
public static Task<Result> TapOnFailure(this Task<Result> resultTask, Func<Error, Task> onFailure, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this Task<Result>
- The task containing the source result.
- onFailure: Func<Error, Task>
- The action executed when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure
public static ValueTask<Result> TapOnFailure(this ValueTask<Result> resultTask, Action<Error> onFailure, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- onFailure: Action<Error>
- The action executed when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure
public static ValueTask<Result> TapOnFailure(this ValueTask<Result> resultTask, Func<Error, ValueTask> onFailure, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- onFailure: Func<Error, ValueTask>
- The action executed when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure<T>
public static Task<Result<T>> TapOnFailure<T>(this Task<Result<T>> resultTask, Action<Error> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- action: Action<Error>
- The side-effect action to execute if the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure<T>
public static Task<Result<T>> TapOnFailure<T>(this Task<Result<T>> resultTask, Func<Error, Task> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- action: Func<Error, Task>
- The side-effect action to execute if the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure<T>
public static ValueTask<Result<T>> TapOnFailure<T>(this ValueTask<Result<T>> resultTask, Action<Error> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- action: Action<Error>
- The side-effect action to execute if the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure<T>
public static ValueTask<Result<T>> TapOnFailure<T>(this ValueTask<Result<T>> resultTask, Func<Error, ValueTask> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- action: Func<Error, ValueTask>
- The side-effect action to execute if the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure<TState, T>
public static Task<Result<T>> TapOnFailure<TState, T>(this Task<Result<T>> resultTask, TState state, Action<TState, Error> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- action: Action<TState, Error>
- The side-effect action to execute if the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure<TState, T>
public static ValueTask<Result<T>> TapOnFailure<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Action<TState, Error> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- action: Action<TState, Error>
- The side-effect action to execute if the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure<TState>
public static Task<Result> TapOnFailure<TState>(this Task<Result> resultTask, TState state, Action<TState, Error> onFailure, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onFailure: Action<TState, Error>
- The action executed with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnFailure<TState>
public static ValueTask<Result> TapOnFailure<TState>(this ValueTask<Result> resultTask, TState state, Action<TState, Error> onFailure, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a failure state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onFailure: Action<TState, Error>
- The action executed with the state and error when the result is a failure.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess
public static Task<Result> TapOnSuccess(this Task<Result> resultTask, Action onSuccess, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this Task<Result>
- The task containing the source result.
- onSuccess: Action
- The action executed when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess
public static Task<Result> TapOnSuccess(this Task<Result> resultTask, Func<Task> onSuccess, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this Task<Result>
- The task containing the source result.
- onSuccess: Func<Task>
- The action executed when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess
public static ValueTask<Result> TapOnSuccess(this ValueTask<Result> resultTask, Action onSuccess, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- onSuccess: Action
- The action executed when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess
public static ValueTask<Result> TapOnSuccess(this ValueTask<Result> resultTask, Func<ValueTask> onSuccess, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- onSuccess: Func<ValueTask>
- The action executed when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess<T>
public static Task<Result<T>> TapOnSuccess<T>(this Task<Result<T>> resultTask, Action<T> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- action: Action<T>
- The side-effect action to execute if the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess<T>
public static Task<Result<T>> TapOnSuccess<T>(this Task<Result<T>> resultTask, Func<T, Task> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- action: Func<T, Task>
- The side-effect action to execute if the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess<T>
public static ValueTask<Result<T>> TapOnSuccess<T>(this ValueTask<Result<T>> resultTask, Action<T> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- action: Action<T>
- The side-effect action to execute if the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess<T>
public static ValueTask<Result<T>> TapOnSuccess<T>(this ValueTask<Result<T>> resultTask, Func<T, ValueTask> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- action: Func<T, ValueTask>
- The side-effect action to execute if the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess<TState, T>
public static Task<Result<T>> TapOnSuccess<TState, T>(this Task<Result<T>> resultTask, TState state, Action<TState, T> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this Task<Result<T>>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- action: Action<TState, T>
- The side-effect action to execute if the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess<TState, T>
public static ValueTask<Result<T>> TapOnSuccess<TState, T>(this ValueTask<Result<T>> resultTask, TState state, Action<TState, T> action, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this ValueTask<Result<T>>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- action: Action<TState, T>
- The side-effect action to execute if the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess<TState>
public static Task<Result> TapOnSuccess<TState>(this Task<Result> resultTask, TState state, Action<TState> onSuccess, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this Task<Result>
- The task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Action<TState>
- The action executed with the state when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the original result.
methodTapOnSuccess<TState>
public static ValueTask<Result> TapOnSuccess<TState>(this ValueTask<Result> resultTask, TState state, Action<TState> onSuccess, CancellationToken cancellationToken = default)
Executes a side-effect action if the asynchronous result is in a success state.
- resultTask: this ValueTask<Result>
- The value task containing the source result.
- state: TState
- The state data forwarded to the delegate to avoid closure allocations.
- onSuccess: Action<TState>
- The action executed with the state when the result is successful.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation. The task result contains the original result.