schema

package
v0.0.0-...-f56171f Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2016 License: MIT Imports: 11 Imported by: 2

Documentation

Overview

Package schema contains the Chitin wire format schema data model and parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope map[uint]Versioned

type Field

type Field struct {
	Name    string
	Kind    FieldType
	Options FieldOptions
}

type FieldOptions

type FieldOptions struct {
	Align uint32
}

type FieldType

type FieldType interface {
	GoType() string

	// Return the data type sufficient to hold data for fast field access.
	GoStateType() string

	// Return a template code snippet that assigns to the field given
	// in stateVar whatever is needed for later fast field access.
	// Local variable `data` is a `[]byte` with the unprocessed part
	// of the message, and is to be updated to point past the current
	// message.
	//
	// If field data is malformed, do `return nil, err`.
	GoFieldPrep(stateVar string) string

	GoFieldGetter(stateVar string) string

	// Return a template code snippet that appends to byte slice
	// `data` the marshaled contents of the field.
	GoFieldBytes(stateVar string) string
	// contains filtered or unexported methods
}

type FixedMessage

type FixedMessage struct {
	WireFormat uint32
	Options    MessageOptions
	Slots      []Slot
}

func (*FixedMessage) GetFields

func (m *FixedMessage) GetFields() []Field

func (*FixedMessage) GetSlots

func (m *FixedMessage) GetSlots() []Slot

type Message

type Message interface {
	GetSlots() []Slot
	GetFields() []Field
	// contains filtered or unexported methods
}

type MessageOptions

type MessageOptions struct {
	Align uint32
}

type Schema

type Schema interface {
	Generate(dst io.Writer, pkg string) error
	// contains filtered or unexported methods
}

func Parse

func Parse(r io.ReadSeeker) (Schema, error)

type SchemaV1

type SchemaV1 struct {
	Envelopes map[string]Envelope
	Messages  map[Versioned]Message
}

func (*SchemaV1) Generate

func (s *SchemaV1) Generate(dst io.Writer, pkg string) error

type Slot

type Slot struct {
	Name string
	Kind SlotType
}

type SlotType

type SlotType interface {
	SlotSize() uint64
	GoType() string
	GoSlotGetter() string
	// Return a template code snippet that sets the slow stored in
	// byte slice `data`.
	// Local variable `v` is the value to be set, of the type returned
	// by GoType.
	GoSlotSetter() string
	// contains filtered or unexported methods
}

type String

type String struct{}

func (String) GoFieldBytes

func (String) GoFieldBytes(stateVar string) string

func (String) GoFieldGetter

func (String) GoFieldGetter(stateVar string) string

func (String) GoFieldPrep

func (String) GoFieldPrep(stateVar string) string

func (String) GoStateType

func (String) GoStateType() string

func (String) GoType

func (String) GoType() string

type Uint16

type Uint16 struct {
}

func (Uint16) GoFieldBytes

func (Uint16) GoFieldBytes(stateVar string) string

func (Uint16) GoFieldGetter

func (Uint16) GoFieldGetter(stateVar string) string

func (Uint16) GoFieldPrep

func (Uint16) GoFieldPrep(stateVar string) string

func (Uint16) GoSlotGetter

func (Uint16) GoSlotGetter() string

func (Uint16) GoSlotSetter

func (Uint16) GoSlotSetter() string

func (Uint16) GoStateType

func (Uint16) GoStateType() string

func (Uint16) GoType

func (Uint16) GoType() string

func (Uint16) SlotSize

func (Uint16) SlotSize() uint64

type VarMessage

type VarMessage struct {
	WireFormat uint32
	Options    MessageOptions
	Slots      []Slot
	Fields     []Field
}

func (*VarMessage) GetFields

func (m *VarMessage) GetFields() []Field

func (*VarMessage) GetSlots

func (m *VarMessage) GetSlots() []Slot

type Versioned

type Versioned struct {
	Name    string
	Version uint32
}

Jump to

Keyboard shortcuts

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