kitchen

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package kitchen is a wire schema that uses every feature the generators support. The conformance test encodes values in Go and checks that the generated Swift and Java decode and re-encode them byte for byte.

Index

Constants

View Source
const SchemaHash uint64 = 0x7315bd8da448f253

SchemaHash identifies this schema's wire layout. Hosts pass it (combined with any other schemas) to nn_start, which refuses a mismatch.

Variables

This section is empty.

Functions

func AppendMessage

func AppendMessage(b []byte, v Message) []byte

AppendMessage appends a Message: its variant index (0 for nil), then the variant.

func AppendOp

func AppendOp(b []byte, v Op) []byte

AppendOp appends a Op: its variant index (0 for nil), then the variant.

func Encode

func Encode(m Message) []byte

Encode returns m's wire encoding: its message id, then its fields.

Types

type Batch

type Batch struct {
	Seq     uint64
	Ops     []Op
	Current Op
}

Batch is a list of ops — the shape of a UI commit.

func (*Batch) AppendWire

func (m *Batch) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Batch) ReadWire

func (m *Batch) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Collections

type Collections struct {
	Names    []string
	Matrix   [][]int32
	Scores   map[string]float64
	ByID     map[uint64]string
	Signed   map[int32]bool
	Nested   map[string][]uint16
	MaybeU32 *uint32
	MaybeS   *string
	MaybeF   *float64
	Kinds    []Kind
	MaybeK   *Kind
	Level    Level
}

Collections covers lists, maps and optionals, nested.

func (*Collections) AppendWire

func (m *Collections) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Collections) ReadWire

func (m *Collections) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Create

type Create struct {
	Parent uint32
	Node   Node
}

Create adds a node.

func (*Create) AppendWire

func (m *Create) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Create) ReadWire

func (m *Create) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Kind

type Kind uint8

Kind is a small enum; values outside the list must survive a round trip.

const (
	KindText Kind = iota
	KindImage
	KindBigText
)

type Level

type Level int16

Level is a signed enum.

const (
	LevelLow  Level = -1
	LevelHigh Level = 1
)

type Message

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

Message is any top-level message in this schema.

func Decode

func Decode(b []byte) (Message, error)

Decode reads exactly one message.

func ReadMessage

func ReadMessage(r *wire.Reader) Message

ReadMessage decodes a Message (nil for index 0).

type Meta

type Meta struct {
	Created int64
	Tags    []string
}

Meta is a plain nested struct.

func (*Meta) AppendWire

func (m *Meta) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Meta) ReadWire

func (m *Meta) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Node

type Node struct {
	ID       uint32
	Kind     Kind
	Label    string
	Props    map[string]string
	Children []*Node
	Meta     *Meta
	Default  string  // a Swift keyword as a field name
	W        float32 // shares its name with generated code's writer
}

Node is a recursive tree, the shape a UI tree will have.

func (*Node) AppendWire

func (m *Node) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Node) ReadWire

func (m *Node) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Op

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

Op is a union: one of several structs.

func ReadOp

func ReadOp(r *wire.Reader) Op

ReadOp decodes a Op (nil for index 0).

type Remove

type Remove struct {
	ID uint32
}

Remove deletes a node.

func (*Remove) AppendWire

func (m *Remove) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Remove) ReadWire

func (m *Remove) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

type Scalars

type Scalars struct {
	B   bool
	U8  uint8
	U16 uint16
	U32 uint32
	U64 uint64
	I8  int8
	I16 int16
	I32 int32
	I64 int64
	I   int
	U   uint
	F32 float32
	F64 float64
	S   string
	Raw []byte
}

Scalars covers every scalar type at the edges of its range.

func (*Scalars) AppendWire

func (m *Scalars) AppendWire(b []byte) []byte

AppendWire appends m's wire encoding to b.

func (*Scalars) ReadWire

func (m *Scalars) ReadWire(r *wire.Reader)

ReadWire decodes m from r. Check r.Err() afterwards.

Jump to

Keyboard shortcuts

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