repeatwire

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const KindChild zapv1.KindByte = 0x62

KindChild is the wire discriminator for Child.

View Source
const KindParent zapv1.KindByte = 0x61

KindParent is the wire discriminator for Parent.

View Source
const OffsetChild_ID = 0

OffsetChild_ID is the byte offset of the ID field.

View Source
const OffsetChild_Name = 8

OffsetChild_Name is the byte offset of the Name field.

View Source
const OffsetParent_Children = 9

OffsetParent_Children is the byte offset of the Children field.

View Source
const OffsetParent_Count = 1

OffsetParent_Count is the byte offset of the Count field.

View Source
const SizeChild = 16

SizeChild is the fixed object payload size in bytes.

View Source
const SizeParent = 17

SizeParent is the fixed object payload size in bytes.

Variables

View Source
var ChildSchemaFields = struct {
	ID zapv1.Field[ChildSchema, uint64]
}{
	ID: zapv1.At[ChildSchema, uint64](0),
}

ChildSchemaFields is the namespace of every scalar field accessor for Child. Use with zapv1.Read / zapv1.Write for type-safe access. Byte-array fields are emitted as standalone functions, see below.

View Source
var ParentSchemaFields = struct {
	Count zapv1.Field[ParentSchema, uint64]
}{
	Count: zapv1.At[ParentSchema, uint64](1),
}

ParentSchemaFields is the namespace of every scalar field accessor for Parent. Use with zapv1.Read / zapv1.Write for type-safe access. Byte-array fields are emitted as standalone functions, see below.

Functions

func 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.

func 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).

func 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).

func 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.ListNestedChildSchema. Zero-copy: each element view indexes straight into the underlying buffer.

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

func 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.

func 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

type Child

type Child struct {
	ID   uint64
	Name string
}

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

type ChildSchema

type ChildSchema struct{}

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

func (ChildSchema) Kind() zapv1.KindByte

func (ChildSchema) Name

func (ChildSchema) Name() string

func (ChildSchema) Size

func (ChildSchema) Size() int

type ParentSchema

type ParentSchema struct{}

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

func (ParentSchema) Kind() zapv1.KindByte

func (ParentSchema) Name

func (ParentSchema) Name() string

func (ParentSchema) Size

func (ParentSchema) Size() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL