wap

package module
v0.0.0-...-958ee23 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: MIT Imports: 6 Imported by: 0

README

WAP (WebAssembly Proto Format)

Moontrade heavily utilizes WebAssembly (TinyGo currently) for running custom code/algorithms to reduce pricing streams into custom data models, execute trades, re-balance portfolios, import/export transformations, etc.

WAP is a flattened buffer format with zero parsing. Given the heavy utilization of numerical computation, numerical types are stored in little-endian binary representation to natively support WASM without needing to transform/parse while supporting all native primitive types of WASM. WAP supports other serialization formats which serialize and deserialize into the flat format.

Given the low-level nature of Wasm, there doesn't exist a uniform way to describe data schemas efficiently without the need to deserialze.

General purpose format. Even though WASM is a primary target, it has first class support to compile schemas to other languages and runtimes (TypeScript/JavaScript, Go, Rust, C#, Python, etc) utilizing the lowest level features of the respective target as much as possible for peak performance and correctness.

Schemas

Schemas are represented in ".wap" files. It's a bit of a hybrid between protobuf and flatbuffer schemas.

Optimized for throughput

MoonProto is all about throughput over size. MoonProto messages can be compressed with a high-performance algorithm like LZ4 which Moontrade uses extensively.

Optimized for streaming

MoonProto is built primarily with streaming in mind. Moontrade utilizes various streaming technologies like Redis, Kafka, PubSub, etc.

Little-endian

MoonProto exclusively uses little-endian. Language implementations of MoonProto may provide support for big-endian format.

JSON Support Built-in

WAP can transparently serialize and deserialize utilizing JSON format while taking advantage of the efficient flat deserialized format.

JSON Short and Long Names

WAP provides the ability to describe 2 names for the same field. Both must be unique within the record. The auto-generated JSON reader will resolve either name.

Protocol Buffers Support Built-in

WAP can transparently serialize and deserialize utilizing Protocol Buffers format while taking advantage of the efficient flat deserialized format.

Browser support

WAP supports TypeScript/JavaScript just dandy. Graphically charting numerical streams (financial charts) is extremely common in web browsers. Moontrade UI uses TypeScript HTML Canvas charting built on top of TradingView.

Variable Sized Buffers

For maximum performance structs are ideal. However, some structures require variable length strings, lists, etc. WAP can support buffers up to 2GB in length.

References

WAP supports references within a single graph. Adding a reference to a type will turn the type into a flexible length type in order to resolve references in the graph.

Anything can be a Root

Reflection

Streaming

WAP provides a custom streaming format.

Logs

Logs timestamped monotonic records

Series

Time-Series records are timestamped monotonic records and have a time range / intervals.

Why not FlatBuffers?

FlatBuffers generally introduces an additional layer of indirection which can make property accesses slower with the added benefit of a more flexible evolutionary data structure. WAP still provides the ability to evolve your schemas, however WAP is geared for "native struct-like" access. In addition, it's important to point out that WAP was designed explicitly to meet Moontrade's product requirements / use cases. A good example of performance issues with FlatBuffers was evident inside Deno before they switched to their own direct (struct-like zero-copy) format. Similar performance gains can be expected for WAP.

In addition, the mutable access pattern for FlatBuffers is awkward.

Documentation

Index

Constants

View Source
const (
	KindUnknown       = Kind(0) // Possibly resolved later
	KindBool          = Kind(1)
	KindByte          = Kind(2)
	KindInt8          = Kind(3)
	KindInt16         = Kind(4)
	KindUInt16        = Kind(5)
	KindInt32         = Kind(6)
	KindUInt32        = Kind(7)
	KindInt64         = Kind(8)
	KindUInt64        = Kind(9)
	KindFloat32       = Kind(10)
	KindFloat64       = Kind(11)
	KindString        = Kind(12)
	KindStringInline  = Kind(13)
	KindBytes         = Kind(14)
	KindBytesInline   = Kind(15)
	KindRecordHeader  = Kind(17)
	KindBlockHeader   = Kind(18)
	KindRef           = Kind(25)
	KindEnum          = Kind(30) // User-defined enum
	KindRecord        = Kind(40) // User-defined variable sized record
	KindStruct        = Kind(41) // User-defined fixed sized record
	KindList          = Kind(50)
	KindListInline    = Kind(51)
	KindMap           = Kind(60)
	KindMapInline     = Kind(61)
	KindUnion         = Kind(70) // User-defined union
	KindUnionUntagged = Kind(71) // User-defined union
	KindStream        = Kind(80)
	KindPad           = Kind(100) // struct alignment padding
)
View Source
const (
	VPointerSize = int32(4)
)

Variables

View Source
var (
	ErrColumnPointer = errors.New("columns cannot be pointer type")
)
View Source
var (
	ErrOutOfMemory = errors.New("out of memory")
)

Functions

func Bytes

func Bytes(p *VPointer) []byte

func Slab

func Slab(p *VPointer) (unsafe.Pointer, int32)

func Slice

func Slice(p *VPointer) unsafe.Pointer

func Str

func Str(p *VPointer) string

Types

type BlockHeader

type BlockHeader struct {
	// contains filtered or unexported fields
}

func (*BlockHeader) BlockSize

func (self *BlockHeader) BlockSize() BlockSize

func (*BlockHeader) Count

func (self *BlockHeader) Count() uint16

func (*BlockHeader) Layout

func (self *BlockHeader) Layout() BlockLayout

func (*BlockHeader) Offset

func (self *BlockHeader) Offset(offset uintptr) unsafe.Pointer

func (*BlockHeader) Size

func (self *BlockHeader) Size() uint16

func (*BlockHeader) SizeU

func (self *BlockHeader) SizeU() uint16

type BlockHeaderMut

type BlockHeaderMut struct {
	BlockHeader
}

func (*BlockHeaderMut) AddCount

func (self *BlockHeaderMut) AddCount(value uint16)

func (*BlockHeaderMut) Append

func (self *BlockHeaderMut) Append(blockSize BlockSize, data unsafe.Pointer, size uintptr) error

func (*BlockHeaderMut) SetBlockSize

func (self *BlockHeaderMut) SetBlockSize(value BlockSize)

func (*BlockHeaderMut) SetCount

func (self *BlockHeaderMut) SetCount(count uint16)

func (*BlockHeaderMut) SetLayout

func (self *BlockHeaderMut) SetLayout(value BlockLayout)

func (*BlockHeaderMut) SetRecord

func (self *BlockHeaderMut) SetRecord(value uint16)

func (*BlockHeaderMut) SetSize

func (self *BlockHeaderMut) SetSize(value uint16)

func (*BlockHeaderMut) SetSizeU

func (self *BlockHeaderMut) SetSizeU(value uint16)

type BlockLayout

type BlockLayout byte
const (
	BlockLayoutRow    BlockLayout = 0
	BlockLayoutColumn BlockLayout = 1
)

type BlockReader

type BlockReader interface {
	Index() int

	Count() int

	Current() (unsafe.Pointer, int)

	First() (unsafe.Pointer, int)

	Last() (unsafe.Pointer, int)

	Prev() (unsafe.Pointer, int)

	Next() (unsafe.Pointer, int)
}

type BlockRecord

type BlockRecord struct {
}

type BlockSize

type BlockSize uint16
const (
	BlockSize1KB  BlockSize = 1024
	BlockSize2KB  BlockSize = 2048
	BlockSize4KB  BlockSize = 4096
	BlockSize8KB  BlockSize = 8192
	BlockSize16KB BlockSize = 16384
	BlockSize32KB BlockSize = 32768
	BlockSize64KB BlockSize = math.MaxUint16
)

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder() *Builder

func (*Builder) Alloc

func (b *Builder) Alloc(length, flex int32) Mutable

func (*Builder) FieldOffset

func (b *Builder) FieldOffset(field *VPointer) int64

func (*Builder) Finish

func (b *Builder) Finish() unsafe.Pointer

func (*Builder) FinishPointer

func (b *Builder) FinishPointer() unsafe.Pointer

func (*Builder) Get

func (b *Builder) Get() *Builder

func (*Builder) Len

func (b *Builder) Len() int

func (*Builder) New

func (b *Builder) New(length, flex int32) Mutable

func (*Builder) OffsetOf

func (b *Builder) OffsetOf(p unsafe.Pointer) int64

func (*Builder) VPointerOffset

func (b *Builder) VPointerOffset(existing *VPointer) int32

type BuilderPointer

type BuilderPointer struct {
	*Builder
}

func AllocBuilder

func AllocBuilder() BuilderPointer

func (*BuilderPointer) Close

func (b *BuilderPointer) Close() error

type BuilderProvider

type BuilderProvider interface {
	Get() *Builder
}

type ColumnBlock

type ColumnBlock struct {
	FixedBlock
}

func (*ColumnBlock) Item

func (h *ColumnBlock) Item(max, offset, size, index uintptr) unsafe.Pointer

func (*ColumnBlock) Slice

func (h *ColumnBlock) Slice(max, offset uintptr) unsafe.Pointer

type ColumnBlockMut

type ColumnBlockMut struct {
	FixedBlockHeaderMut
}

func (*ColumnBlockMut) Item

func (h *ColumnBlockMut) Item(max, offset, size, index uintptr) unsafe.Pointer

func (*ColumnBlockMut) Slice

func (h *ColumnBlockMut) Slice(max, offset uintptr) unsafe.Pointer

type Encoding

type Encoding byte
const (
	EncodingNone   Encoding = 0
	EncodingLZ4    Encoding = 1
	EncodingZSTD   Encoding = 2
	EncodingBrotli Encoding = 3
	EncodingGzip   Encoding = 4
)

type Enum

type Enum struct {
	// contains filtered or unexported fields
}

func (*Enum) Kind

func (e *Enum) Kind() Kind

func (*Enum) Name

func (e *Enum) Name() string

func (*Enum) Options

func (e *Enum) Options() []EnumOption

func (*Enum) SetKind

func (e *Enum) SetKind(kind Kind)

func (*Enum) SetName

func (e *Enum) SetName(name string)

func (*Enum) SetOptions

func (e *Enum) SetOptions(options []EnumOption)

type EnumOption

type EnumOption struct {
	// contains filtered or unexported fields
}

func (*EnumOption) Name

func (e *EnumOption) Name() string

func (*EnumOption) SetName

func (e *EnumOption) SetName(name string)

func (*EnumOption) SetValue

func (e *EnumOption) SetValue(value int64)

func (*EnumOption) SetValueU

func (e *EnumOption) SetValueU(valueU uint64)

func (*EnumOption) Value

func (e *EnumOption) Value() int64

func (*EnumOption) ValueU

func (e *EnumOption) ValueU() uint64

type Expression

type Expression string

type Field

type Field struct {
	// contains filtered or unexported fields
}

Field represents a field on a Record, List Element, or Map Key/Value

func NewField

func NewField(name, short string, dataType Type) Field

func (*Field) Align

func (f *Field) Align() int32

func (*Field) Column

func (f *Field) Column(count int) (offset, size int)

func (*Field) ColumnOffset

func (f *Field) ColumnOffset() int32

func (*Field) Comments

func (f *Field) Comments() []string

func (*Field) IsPointer

func (f *Field) IsPointer() bool

func (*Field) Kind

func (f *Field) Kind() *Type

func (*Field) Name

func (f *Field) Name() string

func (*Field) Number

func (f *Field) Number() uint16

func (*Field) Offset

func (f *Field) Offset() int32

func (*Field) Optional

func (f *Field) Optional() bool

func (*Field) Pointer

func (f *Field) Pointer() bool

func (*Field) SetAlign

func (f *Field) SetAlign(align int32)

func (*Field) SetColumnOffset

func (f *Field) SetColumnOffset(columnOffset int32)

func (*Field) SetComments

func (f *Field) SetComments(comments []string)

func (*Field) SetKind

func (f *Field) SetKind(kind Type)

func (*Field) SetName

func (f *Field) SetName(name string)

func (*Field) SetNumber

func (f *Field) SetNumber(number uint16)

func (*Field) SetOffset

func (f *Field) SetOffset(offset int32)

func (*Field) SetOptional

func (f *Field) SetOptional(optional bool)

func (*Field) SetPointer

func (f *Field) SetPointer(pointer bool)

func (*Field) SetShort

func (f *Field) SetShort(short string)

func (*Field) Short

func (f *Field) Short() string

type FixedBlock

type FixedBlock struct {
	BlockHeader
}

func (*FixedBlock) Reader

func (h *FixedBlock) Reader() *FixedBlockReader

func (*FixedBlock) Record

func (h *FixedBlock) Record(index uintptr) unsafe.Pointer

type FixedBlockHeaderMut

type FixedBlockHeaderMut struct {
	BlockHeaderMut
}

func (*FixedBlockHeaderMut) Append

func (self *FixedBlockHeaderMut) Append(blockSize BlockSize, data unsafe.Pointer, size uintptr) error

type FixedBlockMut

type FixedBlockMut struct {
	BlockHeader
}

func (*FixedBlockMut) Record

func (h *FixedBlockMut) Record(index uintptr) unsafe.Pointer

type FixedBlockReader

type FixedBlockReader struct {
	// contains filtered or unexported fields
}

FixedBlockReader reads fixed sized records

func NewFixedReader

func NewFixedReader(header *BlockHeader) FixedBlockReader

func (*FixedBlockReader) Count

func (fr *FixedBlockReader) Count() int

func (*FixedBlockReader) Current

func (fr *FixedBlockReader) Current() (unsafe.Pointer, int)

func (*FixedBlockReader) CurrentPtr

func (fr *FixedBlockReader) CurrentPtr() unsafe.Pointer

func (*FixedBlockReader) First

func (fr *FixedBlockReader) First() (unsafe.Pointer, int)

func (*FixedBlockReader) FirstPtr

func (fr *FixedBlockReader) FirstPtr() unsafe.Pointer

func (*FixedBlockReader) Index

func (fr *FixedBlockReader) Index() int

func (*FixedBlockReader) Last

func (fr *FixedBlockReader) Last() (unsafe.Pointer, int)

func (*FixedBlockReader) LastPtr

func (fr *FixedBlockReader) LastPtr() unsafe.Pointer

func (*FixedBlockReader) Next

func (fr *FixedBlockReader) Next() (unsafe.Pointer, int)

func (*FixedBlockReader) NextPtr

func (fr *FixedBlockReader) NextPtr() unsafe.Pointer

func (*FixedBlockReader) Prev

func (fr *FixedBlockReader) Prev() (unsafe.Pointer, int)

func (*FixedBlockReader) PrevPtr

func (fr *FixedBlockReader) PrevPtr() unsafe.Pointer

type FlexBlockReader

type FlexBlockReader struct {
	// contains filtered or unexported fields
}

FlexBlockReader reads variable length records. Each record has its uint16 size prepended and appended. uint16 | data | uint16 | uint16 | data | uint16

func (*FlexBlockReader) Count

func (fr *FlexBlockReader) Count() int

func (*FlexBlockReader) Current

func (fr *FlexBlockReader) Current() (unsafe.Pointer, int)

func (*FlexBlockReader) First

func (fr *FlexBlockReader) First() (unsafe.Pointer, int)

func (*FlexBlockReader) Index

func (fr *FlexBlockReader) Index() int

func (*FlexBlockReader) Last

func (fr *FlexBlockReader) Last() (unsafe.Pointer, int)

func (*FlexBlockReader) Next

func (fr *FlexBlockReader) Next() (unsafe.Pointer, int)

func (*FlexBlockReader) Prev

func (fr *FlexBlockReader) Prev() (unsafe.Pointer, int)

type Format

type Format byte
const (
	FormatRaw      Format = 0
	FormatJson     Format = 1
	FormatMoon     Format = 2
	FormatProtobuf Format = 3
	FormatMsgpack  Format = 4
)

type Import

type Import struct {
	// contains filtered or unexported fields
}

type ImportGroup

type ImportGroup struct {
	// contains filtered or unexported fields
}

type Kind

type Kind byte

type Line

type Line struct {
	// contains filtered or unexported fields
}

type List

type List struct {
	// contains filtered or unexported fields
}

List represents an Array like structure. Header: | LEN 2 bytes | [LEN]Element

func (*List) Element

func (l *List) Element() *Type

func (*List) Fixed

func (l *List) Fixed() int

func (*List) SetElement

func (l *List) SetElement(element Type)

func (*List) SetFixed

func (l *List) SetFixed(fixed int)

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map represents a HashMap data structure using a robin-hood algorithm Header: | LEN 2 bytes | SIZE 2 bytes | List<MapEntry> Item: | KEY | VALUE | Distance (2 bytes)

func (*Map) Key

func (m *Map) Key() Type

func (*Map) SetKey

func (m *Map) SetKey(key Type)

func (*Map) SetSize

func (m *Map) SetSize(size int32)

func (*Map) SetValue

func (m *Map) SetValue(value Type)

func (*Map) Size

func (m *Map) Size() int32

func (*Map) Value

func (m *Map) Value() Type

type Mutable

type Mutable struct {
	*Builder
	// contains filtered or unexported fields
}

func (*Mutable) Free

func (b *Mutable) Free(vp *VPointer)

func (Mutable) IsEmpty

func (mut Mutable) IsEmpty() bool

func (*Mutable) IsNil

func (mut *Mutable) IsNil() bool

func (*Mutable) IsRoot

func (mut *Mutable) IsRoot() bool

func (*Mutable) Slice

func (b *Mutable) Slice(p unsafe.Pointer) Mutable

func (*Mutable) SliceAlloc

func (b *Mutable) SliceAlloc(vp *VPointer, size int32) Mutable

SliceAlloc gets the sub Buffer pointed by VPointer allocating if VPointer is 0. It guarantees the sub Buffer is allocated.

func (*Mutable) Unsafe

func (mut *Mutable) Unsafe() unsafe.Pointer

func (*Mutable) WStr

func (b *Mutable) WStr(existing *VPointer, value string)

func (*Mutable) WriteBytes

func (b *Mutable) WriteBytes(existing *VPointer, value []byte)

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func (*Parser) Parse

func (p *Parser) Parse() (*file, error)

type Record

type Record struct {
	// contains filtered or unexported fields
}

func (*Record) Align

func (r *Record) Align() int32

func (*Record) Comments

func (r *Record) Comments() []string

func (*Record) DoLayout

func (record *Record) DoLayout()

func (*Record) Field

func (r *Record) Field(name string) *Field

func (*Record) FieldAt

func (r *Record) FieldAt(index int) *Field

func (*Record) Fields

func (r *Record) Fields() []Field

func (*Record) FieldsMap

func (r *Record) FieldsMap() map[string]*Field

func (*Record) Fixed

func (r *Record) Fixed() bool

func (*Record) Layout

func (r *Record) Layout() RecordLayout

func (*Record) LayoutColumns

func (r *Record) LayoutColumns(offset int32) error

func (*Record) Line

func (r *Record) Line() Line

func (*Record) Name

func (r *Record) Name() string

func (*Record) Offset

func (r *Record) Offset() int32

func (*Record) OptionalOffset

func (r *Record) OptionalOffset() int32

func (*Record) OptionalSize

func (r *Record) OptionalSize() int32

func (*Record) Optionals

func (r *Record) Optionals() int32

func (*Record) SetAlign

func (r *Record) SetAlign(align int32)

func (*Record) SetComments

func (r *Record) SetComments(comments []string)

func (*Record) SetFields

func (r *Record) SetFields(fields []Field)

func (*Record) SetFieldsMap

func (r *Record) SetFieldsMap(fieldsMap map[string]*Field)

func (*Record) SetFixed

func (r *Record) SetFixed(fixed bool)

func (*Record) SetLayout

func (r *Record) SetLayout(layout RecordLayout)

func (*Record) SetLine

func (r *Record) SetLine(line Line)

func (*Record) SetName

func (r *Record) SetName(name string)

func (*Record) SetOffset

func (r *Record) SetOffset(offset int32)

func (*Record) SetOptionalOffset

func (r *Record) SetOptionalOffset(optionalOffset int32)

func (*Record) SetOptionalSize

func (r *Record) SetOptionalSize(optionalSize int32)

func (*Record) SetOptionals

func (r *Record) SetOptionals(optionals int32)

func (*Record) SetSize

func (r *Record) SetSize(size int32)

func (*Record) SetVersion

func (r *Record) SetVersion(version int64)

func (*Record) SetVersionOffset

func (r *Record) SetVersionOffset(versionOffset int32)

func (*Record) SetVersionSize

func (r *Record) SetVersionSize(versionSize int32)

func (*Record) Size

func (r *Record) Size() int32

func (*Record) ToColumns

func (r *Record) ToColumns(columns []*Field) []*Field

func (*Record) Version

func (r *Record) Version() int64

func (*Record) VersionOffset

func (r *Record) VersionOffset() int32

func (*Record) VersionSize

func (r *Record) VersionSize() int32

type RecordHeader

type RecordHeader struct {
	// contains filtered or unexported fields
}

type RecordLayout

type RecordLayout int32
const (
	RecordLayoutCompact RecordLayout = 0
	RecordLayoutAligned RecordLayout = 1
)

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

func (*Schema) Alias

func (s *Schema) Alias() string

func (*Schema) Fqn

func (s *Schema) Fqn() string

func (*Schema) Layout

func (s *Schema) Layout()

func (*Schema) Name

func (s *Schema) Name() string

func (*Schema) SetAlias

func (s *Schema) SetAlias(alias string)

func (*Schema) SetFqn

func (s *Schema) SetFqn(fqn string)

func (*Schema) SetName

func (s *Schema) SetName(name string)

func (*Schema) SetTypes

func (s *Schema) SetTypes(types []Type)

func (*Schema) SetTypesMap

func (s *Schema) SetTypesMap(typesMap map[string]*Type)

func (*Schema) Types

func (s *Schema) Types() []Type

func (*Schema) TypesMap

func (s *Schema) TypesMap() map[string]*Type

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream is a special type for Streaming. It's a list of Records that fits inside 1KB, 2KB, 4KB, 8KB, 16KB, 32KB or 64KB blocks.

func (*Stream) Kind

func (s *Stream) Kind() StreamKind

func (*Stream) Layout

func (s *Stream) Layout() BlockLayout

func (*Stream) Name

func (s *Stream) Name() string

func (*Stream) Record

func (s *Stream) Record() *Record

func (*Stream) SetKind

func (s *Stream) SetKind(kind StreamKind)

func (*Stream) SetLayout

func (s *Stream) SetLayout(layout BlockLayout)

func (*Stream) SetName

func (s *Stream) SetName(name string)

func (*Stream) SetRecord

func (s *Stream) SetRecord(record *Record)

type StreamKind

type StreamKind byte
const (
	StreamKindLog    StreamKind = 0
	StreamKindSeries StreamKind = 1
)

type Type

type Type struct {
	// contains filtered or unexported fields
}

func BytesInlineType

func BytesInlineType(size int32) Type

func BytesType

func BytesType() Type

func ListType

func ListType(element Type) Type

func NumberType

func NumberType(kind Kind) Type

func StringInlineType

func StringInlineType(size int32) Type

func StringType

func StringType() Type

func (*Type) Align

func (d *Type) Align() int32

func (*Type) Enum

func (d *Type) Enum() *Enum

func (*Type) Kind

func (d *Type) Kind() Kind

func (*Type) Line

func (d *Type) Line() Line

func (*Type) List

func (d *Type) List() *List

func (*Type) Map

func (d *Type) Map() *Map

func (*Type) Record

func (d *Type) Record() *Record

func (*Type) SetAlign

func (d *Type) SetAlign(v int32) *Type

func (*Type) SetEnum

func (d *Type) SetEnum(v *Enum) *Type

func (*Type) SetKind

func (d *Type) SetKind(v Kind) *Type

func (*Type) SetLine

func (d *Type) SetLine(line Line)

func (*Type) SetList

func (d *Type) SetList(v *List) *Type

func (*Type) SetMap

func (d *Type) SetMap(v *Map) *Type

func (*Type) SetRecord

func (d *Type) SetRecord(v *Record) *Type

func (*Type) SetSize

func (d *Type) SetSize(v int32) *Type

func (*Type) SetStream

func (d *Type) SetStream(v *Stream) *Type

func (*Type) SetUnion

func (d *Type) SetUnion(v *Union) *Type

func (*Type) Size

func (d *Type) Size() int32

func (*Type) Stream

func (d *Type) Stream() *Stream

func (*Type) Union

func (d *Type) Union() *Union

type Union

type Union struct {
	// contains filtered or unexported fields
}

Union represents a C-like union or a protobuf oneOf

func (*Union) Align

func (union *Union) Align() int32

func (*Union) DoLayout

func (union *Union) DoLayout()

func (*Union) Fields

func (union *Union) Fields() []Field

func (*Union) Kind

func (union *Union) Kind() UnionKind

func (*Union) Name

func (union *Union) Name() string

func (*Union) SetAlign

func (union *Union) SetAlign(align int32)

func (*Union) SetFields

func (union *Union) SetFields(fields []Field)

func (*Union) SetKind

func (union *Union) SetKind(kind UnionKind)

func (*Union) SetName

func (union *Union) SetName(name string)

func (*Union) SetSize

func (union *Union) SetSize(size int32)

func (*Union) Size

func (union *Union) Size() int32

type UnionKind

type UnionKind byte
const (
	UnionKindTagged   UnionKind = 0
	UnionKindUntagged UnionKind = 1
)

type VPointer

type VPointer int32

func (*VPointer) Bytes

func (p *VPointer) Bytes() []byte

func (*VPointer) Deref

func (vp *VPointer) Deref() unsafe.Pointer

func (*VPointer) Len

func (p *VPointer) Len() int32

func (*VPointer) SetLen

func (p *VPointer) SetLen(value int32)

func (*VPointer) Slab

func (p *VPointer) Slab() (unsafe.Pointer, int32)

func (*VPointer) Slice

func (p *VPointer) Slice() unsafe.Pointer

func (*VPointer) Str

func (p *VPointer) Str() string

Directories

Path Synopsis
compile
as
go
go/protobuf
Package protowire parses and formats the raw wire encoding.
Package protowire parses and formats the raw wire encoding.
Package jlexer contains a JSON lexer implementation.
Package jlexer contains a JSON lexer implementation.
intern
Package intern interns strings.
Package intern interns strings.

Jump to

Keyboard shortcuts

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