#ifndef D9BA34A9_3472_4E22_8E82_5C335EDA67C7
#define D9BA34A9_3472_4E22_8E82_5C335EDA67C7

#include <google/protobuf/message_lite.h>
#include <nng/nng.h>

namespace mesytec::mnode::nng
{

// Format is: [u32 size][protobuf message]

// Appends size prefix and serialied message contents to the nng msg.
// Returns the number of bytes written.
size_t serialize_proto_to_nng(const google::protobuf::MessageLite &message, nng_msg *msg);

// Deserializes a protobuf message from an nng msg.
// Returns the number of bytes used (size prefix + message).
size_t deserialize_proto_from_nng(google::protobuf::MessageLite &message, nng_msg *msg);

// Same as above but also trims the message.
size_t deserialize_proto_from_nng_trim(google::protobuf::MessageLite &message, nng_msg *msg);

} // namespace mesytec::mnode::nng

#endif /* D9BA34A9_3472_4E22_8E82_5C335EDA67C7 */
