8#ifndef A11_DATA_MSGPACK_H_
9#define A11_DATA_MSGPACK_H_
15#include <absl/status/status.h>
16#include <absl/status/statusor.h>
17#include <nlohmann/json.hpp>
30 absl::Status
Pack(
const nlohmann::json& value);
49 absl::StatusOr<nlohmann::json>
Read();
57 std::string_view bytes_;
62absl::StatusOr<std::string>
PackStatus(
const absl::Status& status);
64absl::StatusOr<absl::Status>
UnpackStatus(std::string_view bytes);
67nlohmann::json
Binary(std::string_view bytes);
69absl::StatusOr<std::string>
GetBinary(
const nlohmann::json& value,
Sequentially decode the fields of one A11 MessagePack wire record.
Definition msgpack.h:43
absl::StatusOr< nlohmann::json > Read()
Decode the next field and advance the byte cursor.
Definition msgpack.cc:263
MsgpackReader(std::string_view bytes)
Read from bytes, which must remain alive while this reader is used.
Definition msgpack.h:46
absl::Status EnsureFullyConsumed() const
Return an error if unread trailing bytes remain in the record.
Definition msgpack.cc:283
size_t position() const
Current byte offset, useful when diagnosing malformed peer data.
Definition msgpack.h:54
Incrementally encode the fields of one A11 wire record.
Definition msgpack.h:27
std::string TakeBytes()
Transfer the encoded bytes out of this writer.
Definition msgpack.h:36
absl::Status Pack(const nlohmann::json &value)
Append a JSON-compatible field to the encoded record.
Definition msgpack.cc:251
const std::string & bytes() const
View the encoded bytes without transferring ownership.
Definition msgpack.h:33
absl::StatusOr< std::string > GetBinary(const nlohmann::json &value, std::string_view field_name)
Read a binary JSON value, naming field_name in any validation error.
Definition msgpack.cc:295
absl::StatusOr< absl::Status > UnpackStatus(std::string_view bytes)
Decode a structured status without losing A11 status details.
Definition msgpack.cc:319
nlohmann::json Binary(std::string_view bytes)
Wrap arbitrary bytes as a MessagePack binary JSON value.
Definition msgpack.cc:290
absl::StatusOr< std::string > PackStatus(const absl::Status &status)
Encode a structured Abseil status for action and transport status fields.
Definition msgpack.cc:305
Future< T > SubmitWithCancellationHook(absl::AnyInvocable< absl::StatusOr< T >() && > work, std::function< void()> cancellation_hook, thread::TreeOptions tree_options)
Run work on A11's fiber pool with application-specific cancellation.
Definition executor.h:30