wire

package
v0.0.0-...-e4c45ee Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package wire contains a few basic types that can be composed to serialize graph information for the state package. This package defines the wire protocol.

Note that these types are careful about how they implement the relevant interfaces (either value receiver or pointer receiver), so that native-sized types, such as integers and simple pointers, can fit inside the interface object.

This package also uses panic as control flow, so called should be careful to wrap calls in appropriate handlers.

Testing for this package is driven by the state test package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadUint

func LoadUint(r Reader) uint64

LoadUint loads a single unsigned integer.

N.B. This function will panic on error.

func Save

func Save(w Writer, obj Object)

Save saves the given object.

+checkescape all

N.B. This function will panic on error.

func SaveUint

func SaveUint(w Writer, v uint64)

SaveUint saves a single unsigned integer.

N.B. This function will panic on error.

Types

type Array

type Array struct {
	Contents []Object
}

Array is an array value.

type Bool

type Bool bool

Bool is a boolean.

type Complex128

type Complex128 complex128

Complex128 is a 128-bit complex number.

type Complex64

type Complex64 complex128

Complex64 is a 64-bit complex number.

type Dot

type Dot interface {
	// contains filtered or unexported methods
}

Dot is a kind of reference: one of Index and FieldName.

type FieldName

type FieldName string

FieldName is a reference resolution.

type Float32

type Float32 float32

Float32 is a 32-bit floating point number.

type Float64

type Float64 float64

Float64 is a 64-bit floating point number.

type Index

type Index uint32

Index is a reference resolution.

type Int

type Int int64

Int is a signed integer.

This uses varint encoding.

type Interface

type Interface struct {
	Type  TypeSpec
	Value Object
}

Interface is an interface value.

type Map

type Map struct {
	Keys   []Object
	Values []Object
}

Map is a map value.

type Nil

type Nil struct{}

Nil is a primitive zero value of any type.

type Object

type Object interface {
	// contains filtered or unexported methods
}

Object is a generic object.

func Load

func Load(r Reader) Object

Load loads a new object.

+checkescape all

N.B. This function will panic on error.

type Reader

type Reader interface {
	io.Reader
	ReadByte() (byte, error)
}

Reader is the required reader interface.

type Ref

type Ref struct {
	// Root is the root object.
	Root Uint

	// Dots is the set of traversals required from the Root object above.
	// Note that this will be stored in reverse order for efficiency.
	Dots []Dot

	// Type is the base type for the root object. This is non-nil iff Dots
	// is non-zero length (that is, this is a complex reference). This is
	// not *strictly* necessary, but can be used to simplify decoding.
	Type TypeSpec
}

Ref is a reference to an object.

type Slice

type Slice struct {
	Length   Uint
	Capacity Uint
	Ref      Ref
}

Slice is a slice value.

type String

type String string

String is a string.

type Struct

type Struct struct {
	TypeID TypeID
	// contains filtered or unexported fields
}

Struct is a basic composite value.

func (*Struct) Alloc

func (s *Struct) Alloc(slots int)

Alloc allocates the given number of fields.

This must be called before Add and Save.

Precondition: slots must be positive.

func (*Struct) Field

func (s *Struct) Field(i int) *Object

Field returns a pointer to the given field slot.

This must be called after Alloc.

func (*Struct) Fields

func (s *Struct) Fields() int

Fields returns the number of fields.

type Type

type Type struct {
	Name   string
	Fields []string
}

Type is type information.

type TypeID

type TypeID Uint

TypeID is a concrete type ID.

type TypeSpec

type TypeSpec interface {
	// contains filtered or unexported methods
}

TypeSpec is a type dereference.

type TypeSpecArray

type TypeSpecArray struct {
	Count Uint
	Type  TypeSpec
}

TypeSpecArray is an array type.

type TypeSpecMap

type TypeSpecMap struct {
	Key   TypeSpec
	Value TypeSpec
}

TypeSpecMap is a map type.

type TypeSpecNil

type TypeSpecNil struct{}

TypeSpecNil is an empty type.

type TypeSpecPointer

type TypeSpecPointer struct {
	Type TypeSpec
}

TypeSpecPointer is a pointer type.

type TypeSpecSlice

type TypeSpecSlice struct {
	Type TypeSpec
}

TypeSpecSlice is a slice type.

type Uint

type Uint uint64

Uint is an unsigned integer.

type Writer

type Writer interface {
	io.Writer
	WriteByte(byte) error
}

Writer is the required writer interface.

Jump to

Keyboard shortcuts

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