Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CSharpFunctionalExtensions/Result/Methods/FailureAsync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Threading.Tasks;

namespace CSharpFunctionalExtensions
{
public partial struct Result
{
/// <summary>
/// Creates a failure async result with the given error message.
/// </summary>
public static Task<Result> FailureAsync(string error)
{
return new Task<Result>(() => Failure(error));
}

/// <summary>
/// Creates a failure async result with the given error message.
/// </summary>
public static Task<Result<T>> FailureAsync<T>(string error)
{
return new Task<Result<T>>(() => Failure<T>(error));
}

/// <summary>
/// Creates a failure async result with the given error.
/// </summary>
public static Task<Result<T, E>> FailureAsync<T, E>(E error)
{
return new Task<Result<T, E>>(() => Failure<T, E>(error));
}
}
}
31 changes: 31 additions & 0 deletions CSharpFunctionalExtensions/Result/Methods/SuccessAsync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Threading.Tasks;

namespace CSharpFunctionalExtensions
{
public partial struct Result
{
/// <summary>
/// Creates a success async result.
/// </summary>
public static Task<Result> SuccessAsync()
{
return new Task<Result>(() => Success());
}

/// <summary>
/// Creates a success async result containing the given value.
/// </summary>
public static Task<Result<T>> SuccessAsync<T>(T value)
{
return new Task<Result<T>>(() => Success<T>(value));
}

/// <summary>
/// Creates a success async result containing the given value.
/// </summary>
public static Task<Result<T, E>> SuccessAsync<T, E>(T value)
{
return new Task<Result<T,E>>(() => Success<T, E>(value));
}
}
}