package wire
import "gvisor.dev/gvisor/pkg/state/wire"
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 ¶
- func LoadUint(r *Reader) uint64
- func Save(w *Writer, obj Object)
- func SaveUint(w *Writer, v uint64)
- type Array
- type Bool
- type Complex128
- type Complex64
- type Dot
- type FieldName
- type Float32
- type Float64
- type Index
- type Int
- type Interface
- type Map
- type Nil
- type Object
- type Reader
- type Ref
- type Slice
- type String
- type Struct
- func (s *Struct) Alloc(slots int)
- func (s *Struct) Field(i int) *Object
- func (s *Struct) Fields() int
- type Type
- type TypeID
- type TypeSpec
- type TypeSpecArray
- type TypeSpecMap
- type TypeSpecNil
- type TypeSpecPointer
- type TypeSpecSlice
- type Uint
- type Writer
Functions ¶
func LoadUint ¶
LoadUint loads a single unsigned integer.
N.B. This function will panic on error.
func Save ¶
Save saves the given object.
+checkescape all
N.B. This function will panic on error.
func SaveUint ¶
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 ¶
Interface is an interface value.
type Map ¶
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 ¶
Load loads a new object.
+checkescape all
N.B. This function will panic on error.
type Reader ¶
Reader bundles an io.Reader with a buffer used to implement readByte efficiently.
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 ¶
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 ¶
Alloc allocates the given number of fields.
This must be called before Add and Save.
Precondition: slots must be positive.
func (*Struct) Field ¶
Field returns a pointer to the given field slot.
This must be called after Alloc.
func (*Struct) Fields ¶
Fields returns the number of fields.
type Type ¶
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 ¶
TypeSpecArray is an array type.
type TypeSpecMap ¶
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 ¶
Writer bundles an io.Writer with a buffer used to implement writeByte efficiently.
Source Files ¶
wire.go
- Version
- v0.0.0-20250605235530-a6711d1e1dc6 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 4 hours ago –
Tools for package owners.