using System;

namespace ItSystem.Simulator.Base;

public readonly struct BackgroundTaskInfo
{
    public readonly BackgroundTaskState State;
    public readonly Exception Exception;

    private BackgroundTaskInfo(BackgroundTaskState state, Exception exception = null)
    {
        State = state;
        Exception = exception;
    }

    public static BackgroundTaskInfo Success()
    {
        return new BackgroundTaskInfo(BackgroundTaskState.Complete);
    }

    public static BackgroundTaskInfo Busy()
    {
        return new BackgroundTaskInfo(BackgroundTaskState.Busy);
    }

    public static BackgroundTaskInfo Failed(Exception exception)
    {
        return new BackgroundTaskInfo(BackgroundTaskState.Complete, exception);
    }

    public static BackgroundTaskInfo Idle()
    {
        return new BackgroundTaskInfo(BackgroundTaskState.Idle);
    }

}