Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
756 B

using System.Diagnostics.CodeAnalysis;
namespace StabilityMatrix.Core.Models;
public readonly record struct TaskResult<T>
{
public readonly T? Result;
public readonly Exception? Exception;
[MemberNotNullWhen(true, nameof(Result))]
public bool IsSuccessful => Exception is null && Result != null;
1 year ago
public TaskResult(T? result, Exception? exception)
{
1 year ago
Result = result;
Exception = exception;
}
1 year ago
public TaskResult(T result)
{
1 year ago
Result = result;
}
1 year ago
public static TaskResult<T> FromException(Exception exception) => new(default, exception);
public void Deconstruct(out T? result, out Exception? exception)
{
result = Result;
exception = Exception;
}
}