Documentation
¶
Index ¶
- Constants
- Variables
- func ChildName(v zapv1.View[ChildSchema]) string
- func NewChild(iD uint64, name string) (zapv1.View[ChildSchema], []byte)
- func NewParent(count uint64, children []Child) (zapv1.View[ParentSchema], []byte)
- func ParentChildren(v zapv1.View[ParentSchema]) zapv1.ListNested[ChildSchema]
- func WrapChild(b []byte) (zapv1.View[ChildSchema], error)
- func WrapParent(b []byte) (zapv1.View[ParentSchema], error)
- type Child
- type ChildSchema
- type ParentSchema
Constants ¶
const KindChild zapv1.KindByte = 0x62
KindChild is the wire discriminator for Child.
const KindParent zapv1.KindByte = 0x61
KindParent is the wire discriminator for Parent.
const OffsetChild_ID = 0
OffsetChild_ID is the byte offset of the ID field.
const OffsetChild_Name = 8
OffsetChild_Name is the byte offset of the Name field.
const OffsetParent_Children = 9
OffsetParent_Children is the byte offset of the Children field.
const OffsetParent_Count = 1
OffsetParent_Count is the byte offset of the Count field.
const SizeChild = 16
SizeChild is the fixed object payload size in bytes.
const SizeParent = 17
SizeParent is the fixed object payload size in bytes.
Variables ¶
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.
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 ¶
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 ¶
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 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