pub const Tuple = struct container: Containerfn begin(parent: *Serializer, options: ContainerOptions) Error!Tuplepub fn end(self: *Tuple) Error!voidFinishes serializing the tuple.
Prints a trailing comma as configured when appropriate, and the closing bracket.
pub fn field(self: *Tuple, val: anytype, options: ValueOptions) Error!voidSerialize a field. Equivalent to calling fieldPrefix followed by value.
pub fn fieldMaxDepth(self: *Tuple, val: anytype, options: ValueOptions, depth: usize) DepthError!voidSerialize a field. Equivalent to calling fieldPrefix followed by valueMaxDepth. Returns error.ExceededMaxDepth if depth is exceeded.
pub fn fieldArbitraryDepth(self: *Tuple, val: anytype, options: ValueOptions) Error!voidSerialize a field. Equivalent to calling fieldPrefix followed by valueArbitraryDepth.
pub fn beginStructField(self: *Tuple, options: ContainerOptions) Error!StructStarts a field with a struct as a value. Returns the struct.
pub fn beginTupleField(self: *Tuple, options: ContainerOptions) Error!TupleStarts a field with a tuple as a value. Returns the tuple.
pub fn fieldPrefix(self: *Tuple) Error!voidPrint a field prefix. This prints any necessary commas, and whitespace as configured. Useful if you want to serialize the field value yourself.
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620pub const Tuple = struct {
container: Container,
fn begin(parent: *Serializer, options: ContainerOptions) Error!Tuple {
return .{
.container = try Container.begin(parent, .anon, options),
};
}
/// Finishes serializing the tuple.
///
/// Prints a trailing comma as configured when appropriate, and the closing bracket.
pub fn end(self: *Tuple) Error!void {
try self.container.end();
self.* = undefined;
}
/// Serialize a field. Equivalent to calling `fieldPrefix` followed by `value`.
pub fn field(
self: *Tuple,
val: anytype,
options: ValueOptions,
) Error!void {
try self.container.field(null, val, options);
}
/// Serialize a field. Equivalent to calling `fieldPrefix` followed by `valueMaxDepth`.
/// Returns `error.ExceededMaxDepth` if `depth` is exceeded.
pub fn fieldMaxDepth(
self: *Tuple,
val: anytype,
options: ValueOptions,
depth: usize,
) DepthError!void {
try self.container.fieldMaxDepth(null, val, options, depth);
}
/// Serialize a field. Equivalent to calling `fieldPrefix` followed by
/// `valueArbitraryDepth`.
pub fn fieldArbitraryDepth(
self: *Tuple,
val: anytype,
options: ValueOptions,
) Error!void {
try self.container.fieldArbitraryDepth(null, val, options);
}
/// Starts a field with a struct as a value. Returns the struct.
pub fn beginStructField(
self: *Tuple,
options: ContainerOptions,
) Error!Struct {
try self.fieldPrefix();
return self.container.serializer.beginStruct(options);
}
/// Starts a field with a tuple as a value. Returns the tuple.
pub fn beginTupleField(
self: *Tuple,
options: ContainerOptions,
) Error!Tuple {
try self.fieldPrefix();
return self.container.serializer.beginTuple(options);
}
/// Print a field prefix. This prints any necessary commas, and whitespace as
/// configured. Useful if you want to serialize the field value yourself.
pub fn fieldPrefix(self: *Tuple) Error!void {
try self.container.fieldPrefix(null);
}
}
Writes ZON tuples field by field.