////////////////////////////////////////////////////////////
//
// This module contains routines to serialize and deserialize
// lua data structures. These routines can handle cyclic data
// structures.
//
// These routines are used for some specific difference
// transmission cases, but they're not the heart of the lua
// difference transmission system.
// 
////////////////////////////////////////////////////////////


#pragma once

#include "luastack.hpp"
#include "streambuffer.hpp"

// serialize_lua
//
// Serialize a value from the LuaSlot and store it in the StreamBuffer.
// On success, returns empty string.
//
// If there is an error, returns an error message.  In this case, the
// streambuffer contains garbage.
//
eng::string serialize_lua(LuaCoreStack &LS0, LuaSlot val, StreamBuffer *sb);

// deserialize_lua
//
// Deserialize a value from the StreamBuffer and store it in the LuaSlot.
// On success, returns empty string.
//
// If there is an error, returns an error message.  In this case, the
// streambuffer is likely only partially consumed.
//
eng::string deserialize_lua(LuaCoreStack &LS0, LuaSlot val, StreamBuffer *sb);
