Documentation
¶
Overview ¶
Package wire is the runtime for the Nimbus Native wire format: the binary encoding every message between Go and a host uses. Generated code (see wire/gen) calls these functions; apps rarely touch them directly.
Encoding, identical in Go, Swift and Java:
bool 1 byte, 0 or 1 uint8…uint64 unsigned LEB128 varint int8…int64 zigzag, then varint float32, float64 IEEE 754, little-endian, 4 / 8 bytes string, []byte varint length, then the bytes (strings are UTF-8) []T varint count, then each element map[K]V varint count, then key, value pairs sorted by key *T (optional) 1 byte present flag, then the value if present struct its fields in declaration order, no tags union (interface) varint variant index (1-based), then the variant
Structs carry no field tags: both sides are generated from the same schema, and the schema hash checked at nn_start guarantees they match.
Index ¶
- Variables
- func AppendBool(b []byte, v bool) []byte
- func AppendBytes(b []byte, v []byte) []byte
- func AppendFloat32(b []byte, v float32) []byte
- func AppendFloat64(b []byte, v float64) []byte
- func AppendInt(b []byte, v int64) []byte
- func AppendString(b []byte, v string) []byte
- func AppendUint(b []byte, v uint64) []byte
- func Cap(n int) int
- func Combine(hashes []uint64) uint64
- func Combined() uint64
- func Register(pkg string, hash uint64)
- type Reader
- func (r *Reader) Bool() bool
- func (r *Reader) Bytes() []byte
- func (r *Reader) Count() int
- func (r *Reader) Done() error
- func (r *Reader) Err() error
- func (r *Reader) Fail(err error)
- func (r *Reader) Float32() float32
- func (r *Reader) Float64() float64
- func (r *Reader) Int() int64
- func (r *Reader) IntRange(min, max int64) int64
- func (r *Reader) String() string
- func (r *Reader) Uint() uint64
- func (r *Reader) UintMax(max uint64) uint64
Constants ¶
This section is empty.
Variables ¶
var ( ErrShort = errors.New("wire: message ends early") ErrOverflow = errors.New("wire: varint overflows 64 bits") ErrRange = errors.New("wire: value out of range for its type") ErrVariant = errors.New("wire: unknown union variant or message id") ErrTrailing = errors.New("wire: bytes left over after the message") )
Errors a Reader reports. Decoding stops at the first one.
Functions ¶
func AppendBool ¶
func AppendBytes ¶
func AppendFloat32 ¶
func AppendFloat64 ¶
func AppendString ¶
func AppendUint ¶
func Combine ¶
Combine folds schema hashes into one value; order does not matter and no hashes is 0. The generators bake the same value into host code.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader decodes from a byte slice. The first error sticks: later reads return zero values, and Err reports what went wrong. Generated code reads a whole message and checks Err once.
func (*Reader) Count ¶
Count reads a list or map length and checks it is plausible: every element takes at least one byte, so a count beyond the remaining bytes is corrupt.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gen turns a wire schema into code: Go (methods on the schema's own types), Swift (NimbusNativeKit hosts) and Kotlin (Android hosts).
|
Package gen turns a wire schema into code: Go (methods on the schema's own types), Swift (NimbusNativeKit hosts) and Kotlin (Android hosts). |
|
internal
|
|
|
kitchen
Package kitchen is a wire schema that uses every feature the generators support.
|
Package kitchen is a wire schema that uses every feature the generators support. |
|
Package schema reads a wire schema: a Go package of plain types marked with //wire: directives.
|
Package schema reads a wire schema: a Go package of plain types marked with //wire: directives. |