// Copyright (c) 2025 TerraByte Inc.
//
// Defines the public interface for a Promise, which represents the eventual
// completion (or failure) of an asynchronous operation and its resulting value.
// This decouples the consumer from the implementation.

using System;

namespace Terra.Arbitrator.Promises
{
    public enum PromiseState { Pending, Resolved, Rejected }

    public interface IPromise<out TResult>
    {
        /// <summary>
        /// Attaches a callback that will execute when the promise is successfully resolved.
        /// </summary>
        IPromise<TResult> Then(Action<TResult> onResolved);
        
        /// <summary>
        /// Attaches a callback that will execute when the promise is rejected.
        /// </summary>
        IPromise<TResult> Catch(Action<Exception> onRejected);
        
        /// <summary>
        /// Attaches a callback that will execute when the promise is settled (either resolved or rejected).
        /// </summary>
        void Finally(Action onFinally);
    }
}