elm

package
v0.0.0-...-82382f4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// WellKnownTypeMap - map of Google well known type PB identifier to encoder/decoder info
	WellKnownTypeMap = map[string]WellKnownType{
		".google.protobuf.Timestamp": {
			Type:    "Timestamp",
			Decoder: "timestampDecoder",
			Encoder: "timestampEncoder",
		},
		".google.protobuf.Int32Value": {
			Type:    intType,
			Decoder: "intValueDecoder",
			Encoder: "intValueEncoder",
		},
		".google.protobuf.Int64Value": {
			Type:    intType,
			Decoder: "intValueDecoder",
			Encoder: "numericStringEncoder",
		},
		".google.protobuf.UInt32Value": {
			Type:    intType,
			Decoder: "intValueDecoder",
			Encoder: "intValueEncoder",
		},
		".google.protobuf.UInt64Value": {
			Type:    intType,
			Decoder: "intValueDecoder",
			Encoder: "numericStringEncoder",
		},
		".google.protobuf.DoubleValue": {
			Type:    floatType,
			Decoder: "floatValueDecoder",
			Encoder: "floatValueEncoder",
		},
		".google.protobuf.FloatValue": {
			Type:    floatType,
			Decoder: "floatValueDecoder",
			Encoder: "floatValueEncoder",
		},
		".google.protobuf.StringValue": {
			Type:    stringType,
			Decoder: "stringValueDecoder",
			Encoder: "stringValueEncoder",
		},
		".google.protobuf.BytesValue": {
			Type:    bytesType,
			Decoder: "bytesValueDecoder",
			Encoder: "bytesValueEncoder",
		},
		".google.protobuf.BoolValue": {
			Type:    boolType,
			Decoder: "boolValueDecoder",
			Encoder: "boolValueEncoder",
		},
	}
)

Functions

func EnumCustomTypeTemplate

func EnumCustomTypeTemplate(t *template.Template) (*template.Template, error)

EnumCustomTypeTemplate - defines template for an enum custom type

func OneOfCustomTypeTemplate

func OneOfCustomTypeTemplate(t *template.Template) (*template.Template, error)

OneOfCustomTypeTemplate - defines template for a one-of custom type

func TypeAliasTemplate

func TypeAliasTemplate(t *template.Template) (*template.Template, error)

TypeAliasTemplate - defines templates for self contained type aliases

Types

type DefaultValue

type DefaultValue string

func BasicFieldDefaultValue

func BasicFieldDefaultValue(inField *descriptorpb.FieldDescriptorProto) DefaultValue

type EnumCustomType

type EnumCustomType struct {
	Name                   Type
	Decoder                VariableName
	Encoder                VariableName
	DefaultVariantVariable VariableName
	DefaultVariantValue    VariantName
	Variants               []EnumVariant
}

EnumCustomType - defines an Elm custom type (sometimes called union type) for a PB enum https://guide.elm-lang.org/types/custom_types.html

type EnumVariant

type EnumVariant struct {
	Name     VariantName
	Number   ProtobufFieldNumber
	JSONName VariantJSONName
}

EnumVariant - a possible variant of an enum CustomType https://guide.elm-lang.org/types/custom_types.html

type FieldDecoder

type FieldDecoder string

FieldDecoder used in type alias decdoer (ex. )

func OneOfDecoder

func OneOfDecoder(preface []string, pb *descriptorpb.OneofDescriptorProto) FieldDecoder

type FieldEncoder

type FieldEncoder string

FieldEncoder used in type alias decdoer (ex. )

func OneOfEncoder

func OneOfEncoder(preface []string, pb *descriptorpb.OneofDescriptorProto) FieldEncoder

type OneOfCustomType

type OneOfCustomType struct {
	Name     Type
	Decoder  VariableName
	Encoder  VariableName
	Variants []OneOfVariant
}

OneOfCustomType - defines an Elm custom type (sometimes called union type) for a PB one-of https://guide.elm-lang.org/types/custom_types.html

type OneOfVariant

type OneOfVariant struct {
	Name     VariantName
	Type     Type
	JSONName VariantJSONName
	Decoder  VariableName
	Encoder  VariableName
}

OneOfVariant - a possible variant of a one-of CustomType https://guide.elm-lang.org/types/custom_types.html

type ProtobufFieldNumber

type ProtobufFieldNumber int32

ProtobufFieldNumber - unique identifier required for protobuff field declarations Used only for commentsin Elm code generation

type Type

type Type string

Type - Basic Elm type, custom type, or type alias

func BasicFieldType

func BasicFieldType(inField *descriptorpb.FieldDescriptorProto) Type

func ExternalType

func ExternalType(inType string) Type

ExternalType - handles types defined in external files

func ListType

func ListType(t Type) Type

func MapType

func MapType(messagePb *descriptorpb.DescriptorProto) Type

func MaybeType

func MaybeType(t Type) Type

func NestedType

func NestedType(name string, preface []string) Type

NestedType - top level Elm type for a possibly nested PB definition

func OneOfType

func OneOfType(preface []string, in string) Type

type TypeAlias

type TypeAlias struct {
	Name    Type
	Decoder VariableName
	Encoder VariableName
	Fields  []TypeAliasField
}

TypeAlias - defines an Elm type alias (somtimes called a record) https://guide.elm-lang.org/types/type_aliases.html

type TypeAliasField

type TypeAliasField struct {
	Name    VariableName
	Type    Type
	Number  ProtobufFieldNumber
	Decoder FieldDecoder
	Encoder FieldEncoder
}

TypeAliasField - type alias field definition

type VariableName

type VariableName string

VariableName - unique camelcase identifier starting with lowercase letter. Used for both constants and function declarations

func BasicFieldDecoder

func BasicFieldDecoder(inField *descriptorpb.FieldDescriptorProto) VariableName

func BasicFieldEncoder

func BasicFieldEncoder(inField *descriptorpb.FieldDescriptorProto) VariableName

func DecoderName

func DecoderName(t Type) VariableName

DecoderName - decoder function name for Elm type

func EncoderName

func EncoderName(t Type) VariableName

EncoderName - encoder function name for Elm type

func EnumDefaultVariantVariableName

func EnumDefaultVariantVariableName(t Type) VariableName

EnumDefaultVariantVariableName - convenient identifier for a enum custom types default variant

func FieldName

func FieldName(in string) VariableName

FieldName - simple camelcase variable name with first letter lower

type VariantJSONName

type VariantJSONName string

VariantJSONName - unique JSON identifier, uppercase snake case, for a custom type variant

func EnumVariantJSONName

func EnumVariantJSONName(pb *descriptorpb.EnumValueDescriptorProto) VariantJSONName

EnumVariantJSONName - JSON identifier for variant decoder/encoding

func FieldJSONName

FieldJSONName - JSON identifier for field decoder/encoding

func OneOfVariantJSONName

func OneOfVariantJSONName(pb *descriptorpb.FieldDescriptorProto) VariantJSONName

OneOfVariantJSONName - JSON identifier for variant decoder/encoding

type VariantName

type VariantName string

VariantName - unique camelcase identifier used for custom type variants https://guide.elm-lang.org/types/custom_types.html

func NestedVariantName

func NestedVariantName(name string, preface []string) VariantName

NestedVariantName - Elm variant name for a possibly nested PB definition

type WellKnownType

type WellKnownType struct {
	Type    Type
	Encoder VariableName
	Decoder VariableName
}

WellKnownType - information to handle Google well known types

Jump to

Keyboard shortcuts

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