#pragma once

#include <string>

#include <nlohmann/json.hpp>

namespace torlinkc {

// Writes `data` to `file` via write-tmp-then-rename, so a reader never sees a
// half-written file and a crash mid-write never corrupts the previous good
// copy. Creates parent directories as needed. Throws on failure -- callers
// that want a best-effort write (matching the original's swallow-and-ignore
// persistence calls) should catch around it themselves.
void writeJsonAtomic(const std::string& file, const nlohmann::json& data);

}  // namespace torlinkc
