Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Struct

Tuple

Public Struct
std.zon.Serializer.Tuple
pub const Tuple = struct

Writes ZON tuples field by field.

Fields

container: Container

Functions

fn begin(parent: *Serializer, options: ContainerOptions) Error!Tuple
pub fn end(self: *Tuple) Error!void

Finishes 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!void

Serialize a field. Equivalent to calling fieldPrefix followed by value.

pub fn fieldMaxDepth(self: *Tuple, val: anytype, options: ValueOptions, depth: usize) DepthError!void

Serialize 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!void

Serialize a field. Equivalent to calling fieldPrefix followed by valueArbitraryDepth.

pub fn beginStructField(self: *Tuple, options: ContainerOptions) Error!Struct

Starts a field with a struct as a value. Returns the struct.

pub fn beginTupleField(self: *Tuple, options: ContainerOptions) Error!Tuple

Starts a field with a tuple as a value. Returns the tuple.

pub fn fieldPrefix(self: *Tuple) Error!void

Print a field prefix. This prints any necessary commas, and whitespace as configured. Useful if you want to serialize the field value yourself.

File

zon/Serializer.zig:550
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
620
pub 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);
    }
}