// bridge_marshal.cpp — see bridge_marshal.h. Pure; no host types.

#include "bridge_marshal.h"

namespace reasampler::vst {

std::optional<std::string> decodeGetProjExtState(int apiReturn,
                                                 const std::string& buffer) {
    // REAPER returns the length of the stored value; 0 means the key is absent. Guard
    // both the return AND the buffer: a caller that reused a dirty buffer must not
    // surface stale bytes as a value when the API reported nothing.
    if (apiReturn <= 0 || buffer.empty()) return std::nullopt;
    return buffer;
}

}  // namespace reasampler::vst
