protolua

package
v0.1.0-encoding-lua.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ArrayClose = "}"
View Source
const ArrayOpen = "{"
View Source
const BeginString = "\""
View Source
const BoolFalse = "false"
View Source
const BoolTrue = "true"
View Source
const DefaultIndent = "  "
View Source
const EndString = "\""
View Source
const GoogleProtobufParentPackage = "google.protobuf"
View Source
const GoogleProtobufTimestamp = "Timestamp"
View Source
const KeyAssign = "="
View Source
const NullValue = "nil"
View Source
const TableClose = "}"
View Source
const TableOpen = "{"

Variables

This section is empty.

Functions

func Marshal

func Marshal(m proto.Message) ([]byte, error)

Marshal converts the given proto.Message into a lua table using default options. Supports only proto3 messages currently.

Types

type Encoder

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

func NewEncoder

func NewEncoder(indent string) (*Encoder, error)

func (*Encoder) Bytes

func (e *Encoder) Bytes() []byte

func (*Encoder) EndArray

func (e *Encoder) EndArray()

func (*Encoder) EndObject

func (e *Encoder) EndObject()

func (*Encoder) EndString

func (e *Encoder) EndString()

func (*Encoder) StartArray

func (e *Encoder) StartArray()

func (*Encoder) StartObject

func (e *Encoder) StartObject()

func (*Encoder) StartString

func (e *Encoder) StartString()

func (*Encoder) WriteBool

func (e *Encoder) WriteBool(b bool)

WriteBool writes out the given boolean value.

func (*Encoder) WriteIndexedList

func (e *Encoder) WriteIndexedList(i int)

func (*Encoder) WriteInt

func (e *Encoder) WriteInt(n int64)

func (*Encoder) WriteKey

func (e *Encoder) WriteKey(s string) error

func (*Encoder) WriteNull

func (e *Encoder) WriteNull()

WriteNull writes out the null value.

func (*Encoder) WriteNumber

func (e *Encoder) WriteNumber(number string)

func (*Encoder) WriteString

func (e *Encoder) WriteString(s string) error

WriteString escaped the string according to rules needed for luatex

func (*Encoder) WriteUint

func (e *Encoder) WriteUint(n uint64)

type EncodingRun

type EncodingRun struct {
	*Encoder
	// contains filtered or unexported fields
}

type JsonName

type JsonName struct {
}

default for KeyName, will use the jsonName for keys. Except for the root messages where the json name can not be extracted.

type LuaMarshalOption

type LuaMarshalOption struct {
	Format struct {
		// If set to false the lua table with be outputed in one line (default)
		// If set to true the lua table with be outputed in multiple line (better for humans)
		Multiline bool
	}

	// If set to nil, jsonName will be used
	KeyName interface {
		// contains filtered or unexported methods
	}

	// Marshalers for none standard proto messages
	AdditionalMarshalers []interface {
		Handle(fullName protoreflect.FullName) (MarshalFunc, error)
	}
}

func (LuaMarshalOption) Marshal

func (o LuaMarshalOption) Marshal(m proto.Message) ([]byte, error)

Marshal convert the given proto.Message into a lua table using the given options.

type MarshalFunc

type MarshalFunc func(EncodingRun, protoreflect.Message) error

type ProtobufName

type ProtobufName struct {
}

will use protobufName for keys

Jump to

Keyboard shortcuts

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