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.
 
 
 

31 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;
public TaskResult(T? result, Exception? exception)
{
Result = result;
Exception = exception;
}
public TaskResult(T result)
{
Result = result;
}
public static TaskResult<T> FromException(Exception exception) => new(default, exception);
public void Deconstruct(out T? result, out Exception? exception)
{
result = Result;
exception = Exception;
}
}