repeatwire

Package repeatwire

import "github.com/luxfi/zap/v1/codegen/testpkg/repeatwire"

Functions

ChildName

func ChildName(v zapv1.View[ChildSchema]) string

ChildName reads the variable-length Name string field of Child.

Zero-copy: v1's Object.Text returns a string over a sub-slice of the underlying buffer. Valid only while the View's buffer is alive.

NewChild

func NewChild(iD uint64, name string) (zapv1.View[ChildSchema], []byte)

NewChild builds a fresh Child in a ZAP buffer.

Hand-rolled fast path: inlines v1 primitives ([zap.NewBuilder], [*Builder.StartObject], [ObjectBuilder.Set], [*Builder.Finish]) so the entire build expands at the call site. Scalars and fixed byte arrays live in the fixed payload; variable-length string/bytes go in the object tail (the fixed payload holds their 8-byte pointers).

NewParent

func NewParent(count uint64, children []Child) (zapv1.View[ParentSchema], []byte)

NewParent builds a fresh Parent in a ZAP buffer.

Hand-rolled fast path: inlines v1 primitives ([zap.NewBuilder], [*Builder.StartObject], [ObjectBuilder.Set], [*Builder.Finish]) so the entire build expands at the call site. Scalars and fixed byte arrays live in the fixed payload; variable-length string/bytes go in the object tail (the fixed payload holds their 8-byte pointers).

ParentChildren

func ParentChildren(v zapv1.View[ParentSchema]) zapv1.ListNested[ChildSchema]

ParentChildren returns the variable-length Children list of Parent as a range-over-func-ready [zapv1.ListNested][ChildSchema]. Zero-copy: each element view indexes straight into the underlying buffer.

for it := range ParentChildren(view).All() { // zapv1.Read(it, ChildSchemaFields.X) }

WrapChild

func WrapChild(b []byte) (zapv1.View[ChildSchema], error)

WrapChild parses a ZAP buffer into a typed [zapv1.View[Child]]. Validates the wire frame and the kind discriminator at offset 0; returns [*zapv1.SchemaError] on kind mismatch.

Hand-rolled fast path: inlines [zap.Parse] (which is itself inlineable). Zero heap allocs on the happy path; matches v1 hand-rolled performance.

WrapParent

func WrapParent(b []byte) (zapv1.View[ParentSchema], error)

WrapParent parses a ZAP buffer into a typed [zapv1.View[Parent]]. Validates the wire frame and the kind discriminator at offset 0; returns [*zapv1.SchemaError] on kind mismatch.

Hand-rolled fast path: inlines [zap.Parse] (which is itself inlineable). Zero heap allocs on the happy path; matches v1 hand-rolled performance.

Types

Child

Child is the per-element input for the Parent.Children list.

ChildSchema

ChildSchema is the v1 schema marker for Child. Methods are constant- returning so concrete-typed [zapv1.Wrap[ChildSchema]] calls fold to literals at the call site.

func (ChildSchema) Kind() zapv1.KindByte
func (ChildSchema) Name() string
func (ChildSchema) Size() int

ParentSchema

ParentSchema is the v1 schema marker for Parent. Methods are constant- returning so concrete-typed [zapv1.Wrap[ParentSchema]] calls fold to literals at the call site.

func (ParentSchema) Kind() zapv1.KindByte
func (ParentSchema) Name() string
func (ParentSchema) Size() int