Module spacetimedb_table::row_type_visitor
source · Expand description
A VarLenMembers
visitor for [AlgebraicType
],
supporting any non-recursive AlgebraicType
,
including sums and products.
The general architecture is:
first, we walk the AlgebraicType
to construct a [VarLenRoseTree
],
a Rose Tree
with a structure that matches the original AlgebraicType
,
but with non-var-len members stripped out
and var-len members resolved to their offsets within a row.
We then flatten the VarLenRoseTree
into a VarLenVisitorProgram
,
a simple bytecode language which can be interpreted relatively efficiently
to visit the var-len members in a row.
A VarLenVisitorProgram
for a fixed-length-only row will be empty.
A VarLenVisitorProgram
for a (potentially nested) product type
will be a sequence of VisitOffset
instructions,
with no control flow.
SumType
s which contain var-len refs
will introduce control-flow to the VarLenVisitorProgram
using SwitchOnTag
to visit the appropriate variant,
and Goto
to return to the part of the var-len object after the sum.
The VarLenMembers
impl for VarLenVisitorProgram
implements a simple interpreter loop for the var-len visitor bytecode.
Structs§
- A var-len visitor
program
constructed for a particular row typety
, aRowTypeLayout
, usingrow_type_visitor
, which is the only way a program can be produced. - The iterator type for
VarLenVisitorProgram::visit_var_len
. - The iterator type for
VarLenVisitorProgram::visit_var_len_mut
.
Functions§
- Construct an implementor of
VarLenMembers
, which visits the var-len members in a row ofty
.