Writes ZON tuples field by field.
container: Containerpub fn end(self: *Tuple) Writer.Error!voidFinishes serializing the tuple.
Prints a trailing comma as configured when appropriate, and the closing bracket.
self: *Tuplepub fn end(self: *Tuple) Writer.Error!void {
try self.container.end();
self.* = undefined;
}pub fn field( self: *Tuple, val: anytype, options: ValueOptions, ) Writer.Error!voidSerialize a field. Equivalent to calling fieldPrefix followed by value.
self: *Tupleoptions: ValueOptionspub fn field(
self: *Tuple,
val: anytype,
options: ValueOptions,
) Writer.Error!void {
try self.container.field(null, val, options);
}pub fn fieldMaxDepth( self: *Tuple, val: anytype, options: ValueOptions, depth: usize, ) (Writer.Error || error{ExceededMaxDepth})!voidSerialize a field. Equivalent to calling fieldPrefix followed by valueMaxDepth.
pub fn fieldMaxDepth(
self: *Tuple,
val: anytype,
options: ValueOptions,
depth: usize,
) (Writer.Error || error{ExceededMaxDepth})!void {
try self.container.fieldMaxDepth(null, val, options, depth);
}pub fn fieldArbitraryDepth( self: *Tuple, val: anytype, options: ValueOptions, ) Writer.Error!voidSerialize a field. Equivalent to calling fieldPrefix followed by
valueArbitraryDepth.
self: *Tupleoptions: ValueOptionspub fn fieldArbitraryDepth(
self: *Tuple,
val: anytype,
options: ValueOptions,
) Writer.Error!void {
try self.container.fieldArbitraryDepth(null, val, options);
}pub fn beginStructField( self: *Tuple, options: SerializeContainerOptions, ) Writer.Error!StructStarts a field with a struct as a value. Returns the struct.
self: *Tupleoptions: SerializeContainerOptionspub fn beginStructField(
self: *Tuple,
options: SerializeContainerOptions,
) Writer.Error!Struct {
try self.fieldPrefix();
return self.container.serializer.beginStruct(options);
}pub fn beginTupleField( self: *Tuple, options: SerializeContainerOptions, ) Writer.Error!TupleStarts a field with a tuple as a value. Returns the tuple.
self: *Tupleoptions: SerializeContainerOptionspub fn beginTupleField(
self: *Tuple,
options: SerializeContainerOptions,
) Writer.Error!Tuple {
try self.fieldPrefix();
return self.container.serializer.beginTuple(options);
}pub fn fieldPrefix(self: *Tuple) Writer.Error!voidPrint a field prefix. This prints any necessary commas, and whitespace as configured. Useful if you want to serialize the field value yourself.
self: *Tuplepub fn fieldPrefix(self: *Tuple) Writer.Error!void {
try self.container.fieldPrefix(null);
}pub const Tuple = struct {
container: Container,
fn begin(parent: *Self, options: SerializeContainerOptions) Writer.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) Writer.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,
) Writer.Error!void {
try self.container.field(null, val, options);
}
/// Serialize a field. Equivalent to calling `fieldPrefix` followed by `valueMaxDepth`.
pub fn fieldMaxDepth(
self: *Tuple,
val: anytype,
options: ValueOptions,
depth: usize,
) (Writer.Error || error{ExceededMaxDepth})!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,
) Writer.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: SerializeContainerOptions,
) Writer.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: SerializeContainerOptions,
) Writer.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) Writer.Error!void {
try self.container.fieldPrefix(null);
}
}