A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::data::MsgpackReader Class Reference

Sequentially decode the fields of one A11 MessagePack wire record. More...

#include <cpp/a11/data/msgpack.h>

Public Member Functions

 MsgpackReader (std::string_view bytes)
 Read from bytes, which must remain alive while this reader is used.
 
absl::StatusOr< nlohmann::json > Read ()
 Decode the next field and advance the byte cursor.
 
absl::StatusOr< std::string_view > ReadBinaryView ()
 Read the next field as MessagePack binary without copying its payload.
 
absl::StatusOr< size_t > ReadArrayLength ()
 Read the next field as a MessagePack array header, returning its length.
 
absl::Status EnsureFullyConsumed () const
 Return an error if unread trailing bytes remain in the record.
 
size_t position () const
 Current byte offset, useful when diagnosing malformed peer data.
 

Detailed Description

Sequentially decode the fields of one A11 MessagePack wire record.

Constructor & Destructor Documentation

◆ MsgpackReader()

a11::data::MsgpackReader::MsgpackReader ( std::string_view  bytes)
inlineexplicit

Read from bytes, which must remain alive while this reader is used.

Member Function Documentation

◆ EnsureFullyConsumed()

absl::Status a11::data::MsgpackReader::EnsureFullyConsumed ( ) const

Return an error if unread trailing bytes remain in the record.

◆ position()

size_t a11::data::MsgpackReader::position ( ) const
inline

Current byte offset, useful when diagnosing malformed peer data.

◆ Read()

absl::StatusOr< nlohmann::json > a11::data::MsgpackReader::Read ( )

Decode the next field and advance the byte cursor.

◆ ReadArrayLength()

absl::StatusOr< size_t > a11::data::MsgpackReader::ReadArrayLength ( )

Read the next field as a MessagePack array header, returning its length.

Lets a caller iterate a list of binary records with ReadBinaryView() instead of materialising the whole array as JSON first.

◆ ReadBinaryView()

absl::StatusOr< std::string_view > a11::data::MsgpackReader::ReadBinaryView ( )

Read the next field as MessagePack binary without copying its payload.

The returned view points into the buffer this reader was constructed over, which must outlive it.


The documentation for this class was generated from the following files: