Documentation ¶
Overview ¶
Package zcode implements serialization and deserialzation for ZNG values.
Values of primitive type are represented by an unsigned integer tag and an optional byte-sequence body. A tag of zero indicates that the value is unset, and no body follows. A nonzero tag indicates that the value is set, and the value itself follows as a body of length tag-1.
Values of union type are represented similarly, with the body prefixed by an integer specifying the index determining the type of the value in reference to the union type.
Values of container type (record, set, or array) are represented similarly, with the body containing a sequence of zero or more serialized values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotContainer = errors.New("not a container") ErrNotSingleton = errors.New("not a single container") )
Functions ¶
func AppendUvarint ¶
AppendUvarint is like encoding/binary.PutUvarint but appends to dst instead of writing into it.
func DecodeCountedUvarint ¶
func DecodeCountedVarint ¶
func EncodeCountedUvarint ¶
func EncodeCountedVarint ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides an efficient API for constructing nested ZNG values.
func (*Builder) AppendContainer ¶
AppendContainer appends val as a container value.
func (*Builder) AppendPrimitive ¶
AppendPrimitive appends val as a primitive value.
func (*Builder) BeginContainer ¶
func (b *Builder) BeginContainer()
BeginContainer opens a new container.
func (*Builder) Bytes ¶
Bytes returns the constructed value. It panics if the receiver has an open container.
func (*Builder) EndContainer ¶
func (b *Builder) EndContainer()
EndContainer closes the most recently opened container. It panics if the receiver has no open container.
func (*Builder) TransformContainer ¶ added in v0.2.0
TransformContainer calls transform, passing it the body of the most recently opened container and replacing the original body with the return value. It panics if the receiver has no open container.
type Bytes ¶
type Bytes []byte
Bytes is the serialized representation of a sequence of ZNG values.
func AppendContainer ¶
AppendContainer appends val to dst as a container value and returns the extended buffer.
func AppendPrimitive ¶
AppendPrimitive appends val to dst as a primitive value and returns the extended buffer.
func (Bytes) ContainerBody ¶
ContainerBody returns the body of the receiver, which must hold a single container. If the receiver is not a container, ErrNotContainer is returned. If the receiver is not a single container, ErrNotSingleton is returned.