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

One piece of a node's stream: an inline chunk or a node reference. More...

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

Public Member Functions

size_t ApproxBytes () const
 Estimate memory/wire weight for session and transport limits.
 
std::string DebugString () const
 Return a concise representation suitable for logs and diagnostics.
 
absl::Status Validate () const
 Validate the node id, payload, sequence, and continuation marker.
 
absl::StatusOr< Chunk *absl_nonnull > GetChunk ()
 Returns the held Chunk, or an error when it holds a NodeRef.
 
absl::StatusOr< const Chunk *absl_nonnull > GetChunk () const
 Returns the held Chunk, or an error when it holds a NodeRef.
 
absl::StatusOr< NodeRef *absl_nonnull > GetNodeRef ()
 Returns the held NodeRef, or an error when it holds a Chunk.
 
absl::StatusOr< const NodeRef *absl_nonnull > GetNodeRef () const
 Returns the held NodeRef, or an error when it holds a Chunk.
 
absl::StatusOr< Bytes > ToMsgpack () const
 Encodes this fragment as MessagePack bytes.
 
absl::Status ToMsgpackInto (MsgpackWriter *absl_nonnull writer) const
 Append this record's fields to an already-open writer.
 

Static Public Member Functions

static absl::StatusOr< NodeFragment > FromMsgpack (std::string_view bytes)
 Decodes MessagePack bytes into a NodeFragment.
 

Public Attributes

std::string id = {}
 Id of the node this fragment belongs to.
 
std::variant< Chunk, NodeRef > data = Chunk{}
 Inline chunk or reference.
 
std::optional< std::uint32_t > seq = {}
 Ordering sequence number.
 
bool continued = false
 Whether further fragments follow this one.
 

Friends

bool operator== (const NodeFragment &, const NodeFragment &)=default
 
template<typename Sink >
void AbslStringify (Sink &sink, const NodeFragment &value)
 

Detailed Description

One piece of a node's stream: an inline chunk or a node reference.

Fragments are how data flows through a named node. Each targets a node by id and carries either a Chunk or a NodeRef. seq orders fragments within the node and continued marks that more fragments follow (the stream is not yet complete).

Member Function Documentation

◆ ApproxBytes()

size_t a11::data::NodeFragment::ApproxBytes ( ) const

Estimate memory/wire weight for session and transport limits.

◆ DebugString()

std::string a11::data::NodeFragment::DebugString ( ) const

Return a concise representation suitable for logs and diagnostics.

◆ FromMsgpack()

absl::StatusOr< NodeFragment > a11::data::NodeFragment::FromMsgpack ( std::string_view  bytes)
static

Decodes MessagePack bytes into a NodeFragment.

◆ GetChunk() [1/2]

absl::StatusOr< Chunk *absl_nonnull > a11::data::NodeFragment::GetChunk ( )

Returns the held Chunk, or an error when it holds a NodeRef.

◆ GetChunk() [2/2]

absl::StatusOr< const Chunk *absl_nonnull > a11::data::NodeFragment::GetChunk ( ) const

Returns the held Chunk, or an error when it holds a NodeRef.

◆ GetNodeRef() [1/2]

absl::StatusOr< NodeRef *absl_nonnull > a11::data::NodeFragment::GetNodeRef ( )

Returns the held NodeRef, or an error when it holds a Chunk.

◆ GetNodeRef() [2/2]

absl::StatusOr< const NodeRef *absl_nonnull > a11::data::NodeFragment::GetNodeRef ( ) const

Returns the held NodeRef, or an error when it holds a Chunk.

◆ ToMsgpack()

absl::StatusOr< Bytes > a11::data::NodeFragment::ToMsgpack ( ) const

Encodes this fragment as MessagePack bytes.

◆ ToMsgpackInto()

absl::Status a11::data::NodeFragment::ToMsgpackInto ( MsgpackWriter *absl_nonnull  writer) const

Append this record's fields to an already-open writer.

What ToMsgpack() is built from, and what a parent record calls through MsgpackWriter::PackRecord so that nesting costs no buffer of its own. Both produce the same bytes; this one avoids the intermediate string.

Assumes the record is already valid. Validate() recurses through nested records, so validating here as well would re-check every nested id once per ancestor level. ToMsgpack() validates the whole tree once and then calls this; a caller reaching for this directly should do the same, and any caller that got its record from FromMsgpack() already has.

◆ Validate()

absl::Status a11::data::NodeFragment::Validate ( ) const

Validate the node id, payload, sequence, and continuation marker.

Friends And Related Symbol Documentation

◆ AbslStringify

template<typename Sink >
void AbslStringify ( Sink &  sink,
const NodeFragment &  value 
)
friend

◆ operator==

bool operator== ( const NodeFragment &  ,
const NodeFragment &   
)
friend

Member Data Documentation

◆ continued

bool a11::data::NodeFragment::continued = false

Whether further fragments follow this one.

◆ data

std::variant<Chunk, NodeRef> a11::data::NodeFragment::data = Chunk{}

Inline chunk or reference.

◆ id

std::string a11::data::NodeFragment::id = {}

Id of the node this fragment belongs to.

◆ seq

std::optional<std::uint32_t> a11::data::NodeFragment::seq = {}

Ordering sequence number.


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