15#ifndef ACTIONENGINE_MSGPACK_MSGPACK_H 
   16#define ACTIONENGINE_MSGPACK_MSGPACK_H 
   23#include <absl/status/status.h> 
   26#include "actionengine/msgpack/array.h" 
   27#include "actionengine/msgpack/core_helpers.h" 
   28#include "actionengine/msgpack/float.h" 
   29#include "actionengine/msgpack/int.h" 
   30#include "actionengine/msgpack/misc.h" 
   31#include "actionengine/msgpack/strbin.h" 
   35namespace act::msgpack {
 
   39  explicit Packer(SerializedBytesVector bytes = {});
 
   42  absl::Status Pack(
const T& value) {
 
   43    InsertInfo insert{&bytes_, bytes_.end()};
 
   44    return EgltMsgpackSerialize(value, insert);
 
   48  absl::Status Unpack(T& destination) {
 
   49    if (offset_ >= bytes_.size()) {
 
   50      return absl::InvalidArgumentError(
"Offset is out of bounds.");
 
   52    const auto pos = bytes_.data() + offset_;
 
   53    const auto end = bytes_.data() + bytes_.size();
 
   54    auto deserialized_extent =
 
   55        Deserialize<T>(LookupPointer(pos, end), &destination);
 
   56    if (!deserialized_extent.ok()) {
 
   57      return deserialized_extent.status();
 
   59    offset_ += *deserialized_extent;
 
   60    return absl::OkStatus();
 
   65  void Reserve(
size_t size);
 
   67  [[nodiscard]] 
const SerializedBytesVector& GetVector() 
const;
 
   69  [[nodiscard]] std::vector<Byte> GetStdVector() 
const;
 
   71  SerializedBytesVector ReleaseVector();
 
   73  std::vector<Byte> ReleaseStdVector();
 
   76  SerializedBytesVector bytes_;