Value
struct Value
One Avro datum. Cheap to copy: the node arena is shared.
Implements Copyable, Equatable, Movable, Sized, Writable
- Fields
arena: ArcPointer[List[ValueNode]]idx: Int
__init__
def __init__(out self, var arena: ArcPointer[List[ValueNode]], idx: Int)
__eq__
def __eq__(self, other: Self) -> Bool
__ne__
def __ne__(self, other: Self) -> Bool
boolean
def boolean(v: Bool) -> Self
int
def int(v: Int64) -> Self
long
def long(v: Int64) -> Self
float
def float(v: Float32) -> Self
double
def double(v: Float64) -> Self
bytes
def bytes(v: Span[UInt8]) -> Self
fixed
def fixed(v: Span[UInt8]) -> Self
string
def string(v: StringSpan) -> Self
enum
def enum(index: Int, symbol: StringSpan) -> Self
array
def array(items: List[Self]) -> Self
map
def map(var keys: List[String], values: List[Self]) -> Self
record
def record(var names: List[String], values: List[Self]) -> Self
union
def union(index: Int, branch: Self) -> Self
type_name
def type_name(self) -> String
is_null
def is_null(self) -> Bool
as_bool
def as_bool(self) -> Bool
as_long
def as_long(self) -> Int64
as_int
def as_int(self) -> Int32
as_double
def as_double(self) -> Float64
as_float
def as_float(self) -> Float32
as_string
def as_string(self) -> String
as_bytes
def as_bytes(self) -> List[UInt8]
enum_index
def enum_index(self) -> Int
symbol
def symbol(self) -> String
union_index
def union_index(self) -> Int
unwrap
def unwrap(self) -> Self
The branch value of a union; self for anything else.
at
def at(self, k: Int) -> Self
Child k — an array element, map value or record field value.
key
def key(self, k: Int) -> String
Name of child k — a record field name or a map key.
index_of
def index_of(self, name: StringSpan) -> Int
Position of a record field or map key, or -1 when absent.
has
def has(self, name: StringSpan) -> Bool
field
def field(self, name: StringSpan) -> Self
A record field (or map entry) by name, unwrapping unions.
field_raw
def field_raw(self, name: StringSpan) -> Self
A record field by name, keeping any union wrapper.
to_json
def to_json(self) -> String
A JSON rendering used by the tests and the fastavro cross-check.
Unions collapse to their branch value and bytes/fixed render as
"0x…" hex, so the output lines up with a Python dict dumped the
same way.
write_to
def write_to(self, mut writer: T)
RecordBuilder
struct RecordBuilder
Accumulate named fields, then build() a record Value.
var b = RecordBuilder()
b.add("id", Value.long(7))
b.add("name", Value.string("row"))
var v = b^.build()
Implements Copyable, Defaultable, Movable
- Fields
names: List[String]values: List[Value]
add
def add(mut self, name: StringSpan, value: Value)
build
def build(deinit self) -> Value
ArrayBuilder
struct ArrayBuilder
Accumulate elements, then build() an array Value.
Implements Copyable, Defaultable, Movable
- Fields
values: List[Value]
add
def add(mut self, value: Value)
build
def build(deinit self) -> Value
MapBuilder
struct MapBuilder
Accumulate key/value pairs, then build() a map Value.
Implements Copyable, Defaultable, Movable
- Fields
keys: List[String]values: List[Value]
add
def add(mut self, key: StringSpan, value: Value)
build
def build(deinit self) -> Value