//------------------------------------------------------------------------------
/*
    This file is part of clio: https://github.com/XRPLF/clio
    Copyright (c) 2024, the clio developers.

    Permission to use, copy, modify, and distribute this software for any
    purpose with or without fee is hereby granted, provided that the above
    copyright notice and this permission notice appear in all copies.

    THE  SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    WITH  REGARD  TO  THIS  SOFTWARE  INCLUDING  ALL  IMPLIED  WARRANTIES  OF
    MERCHANTABILITY  AND  FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    ANY  SPECIAL,  DIRECT,  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    WHATSOEVER  RESULTING  FROM  LOSS  OF USE, DATA OR PROFITS, WHETHER IN AN
    ACTION  OF  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================

#pragma once

#include "etl/Models.hpp"

#include <xrpl/protocol/LedgerHeader.h>

#include <expected>
#include <optional>

namespace etl {

/**
 * @brief Enumeration of possible errors that can occur during loading operations
 */
enum class LoaderError {
    AmendmentBlocked, /*< Error indicating that an operation is blocked by an amendment */
    WriteConflict,    /*< Error indicating that a write operation resulted in a conflict */
};

/**
 * @brief An interface for a ETL Loader
 */
struct LoaderInterface {
    virtual ~LoaderInterface() = default;

    /**
     * @brief Load ledger data
     * @param data The data to load
     * @return Nothing or error as std::expected
     */
    [[nodiscard]] virtual std::expected<void, LoaderError>
    load(model::LedgerData const& data) = 0;

    /**
     * @brief Load the initial ledger
     * @param data The data to load
     * @return Optional ledger header
     */
    [[nodiscard]] virtual std::optional<ripple::LedgerHeader>
    loadInitialLedger(model::LedgerData const& data) = 0;
};

}  // namespace etl
