protolua

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 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 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)

func (*Encoder) WriteIndexedList

func (e *Encoder) WriteIndexedList(i int)

func (*Encoder) WriteKey

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

func (*Encoder) WriteNull

func (e *Encoder) WriteNull()

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

type EncodingRun

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

type GoogleWellKnownTypesMarshaler

type GoogleWellKnownTypesMarshaler struct {
}

func (GoogleWellKnownTypesMarshaler) Handle

GoogleWellKnownTypesMarshaler returns a marshal function for message of the package "google.protobuf" it returns an error in case of types of this packages are not supported yet. it returns nil if the package is different.

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 output is formated as one line (default)
		// If set to true the output is formated in multiple line with indent (better for humans)
		Multiline bool
	}

	// Defines how the name of message are crated
	// If set to nil, [protolua.JsonName] will be used
	KeyName interface {
		// contains filtered or unexported methods
	}

	// Additional Marshalers for non standard proto messages
	// see [protolua.GoogleWellKnownTypesMarshaler] for an example
	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