// bridge_marshal — pure GetProjExtState result decode for the REAPER VST-host bridge read.
//
// Verified against vendor/reaper-sdk/sdk/reaper_plugin_functions.h:
//   int GetProjExtState(ReaProject*, extname, key, valOutNeedBig, valOutNeedBig_sz)
//   returns the length written (0 when the key is absent).

#pragma once

#include <optional>
#include <string>
#include <utility>
#include <vector>

namespace reasampler::instrument::map {

// Value only when the API reported non-empty AND the buffer is non-empty — REAPER
// writes 0 and leaves the buffer untouched for an absent key, so stale buffer
// contents must never read as a hit.
std::optional<std::string> decodeGetProjExtState(int apiReturn,
                                                  const std::string& buffer);

}  // namespace reasampler::instrument::map
