encoding

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package encoding implements the cloudstate Any encoding support.

Index

Constants

View Source
const (
	PrimitiveTypeURLPrefix = "p.cloudstate.io"
	ProtoAnyBase           = "type.googleapis.com"

	PrimitiveTypeURLPrefixInt32  = PrimitiveTypeURLPrefix + "/int32"
	PrimitiveTypeURLPrefixInt64  = PrimitiveTypeURLPrefix + "/int64"
	PrimitiveTypeURLPrefixString = PrimitiveTypeURLPrefix + "/string"
	PrimitiveTypeURLPrefixFloat  = PrimitiveTypeURLPrefix + "/float"
	PrimitiveTypeURLPrefixDouble = PrimitiveTypeURLPrefix + "/double"
	PrimitiveTypeURLPrefixBool   = PrimitiveTypeURLPrefix + "/bool"
	PrimitiveTypeURLPrefixBytes  = PrimitiveTypeURLPrefix + "/bytes"
)
View Source
const (
	JSONTypeURLPrefix = "json.cloudstate.io"
)

Variables

View Source
var Empty, _ = MarshalAny(&empty.Empty{})
View Source
var ErrMarshal = errors.New("unable to marshal a message")
View Source
var ErrNotMarshalled = errors.New("not marshalled")
View Source
var ErrNotUnmarshalled = errors.New("not unmarshalled")

Functions

func Bool added in v0.2.0

func Bool(b bool) *any.Any

func Bytes added in v0.2.0

func Bytes(b []byte) *any.Any

func DecodeBool added in v0.2.0

func DecodeBool(a *any.Any) bool

func DecodeBytes added in v0.2.0

func DecodeBytes(a *any.Any) []byte

func DecodeFloat32 added in v0.2.0

func DecodeFloat32(a *any.Any) float32

func DecodeFloat64 added in v0.2.0

func DecodeFloat64(a *any.Any) float64

func DecodeInt32 added in v0.2.0

func DecodeInt32(a *any.Any) int32

func DecodeInt64 added in v0.2.0

func DecodeInt64(a *any.Any) int64

func DecodeString added in v0.2.0

func DecodeString(a *any.Any) string

func DecodeStruct added in v0.2.0

func DecodeStruct(a *any.Any, s interface{}) error

func Float32 added in v0.2.0

func Float32(f float32) *any.Any

func Float64 added in v0.2.0

func Float64(f float64) *any.Any

func Int32 added in v0.2.0

func Int32(i int32) *any.Any

func Int64 added in v0.2.0

func Int64(i int64) *any.Any

func JSON added in v0.2.0

func JSON(value interface{}) (*any.Any, error)

func MarshalAny added in v0.2.0

func MarshalAny(pb interface{}) (*any.Any, error)

MarshalAny marshals a proto.Message to an any.Any value.

func MarshalJSON

func MarshalJSON(value interface{}) (*any.Any, error)

MarshalJSON encodes a struct type into its Cloudstate Any JSON value.

func MarshalPrimitive

func MarshalPrimitive(i interface{}) (*any.Any, error)

func String added in v0.2.0

func String(s string) *any.Any

func StringMust added in v0.2.0

func StringMust(s string) *any.Any

func Struct added in v0.2.0

func Struct(s interface{}) (*any.Any, error)

func UnmarshalAny added in v0.2.0

func UnmarshalAny(x *any.Any, p proto.Message) error

func UnmarshalJSON

func UnmarshalJSON(any *any.Any, target interface{}) error

UnmarshalPrimitive decodes a Cloudstate Any protobuf message into its JSON value.

func UnmarshalPrimitive

func UnmarshalPrimitive(any *any.Any) (interface{}, error)

UnmarshalPrimitive decodes a CloudState Any proto message into its primitive value.

Types

type AnyDecFunc added in v0.2.0

type AnyDecFunc func(any *any.Any, target interface{}) error

type AnyEncFunc added in v0.2.0

type AnyEncFunc func(i interface{}) (*any.Any, error)

Jump to

Keyboard shortcuts

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