codecutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckValueType

func CheckValueType(v any) error

func NormalizeValue

func NormalizeValue(value any) (any, reflect.Type)

Internally values are always pointers to a non-pointer type.

func PrepareMarshalValue

func PrepareMarshalValue(v any) (reflect.Value, proto.Message, error)

Validate the input value for marshalling.

func PrepareUnmarshalDest

func PrepareUnmarshalDest(v any) (reflect.Value, proto.Message, error)

Validate the output destination for unmarshalling. It must be a non-nil pointer.

func Unmarshal

func Unmarshal(c Codec, data []byte, valueType reflect.Type) (any, error)

Unmarshal decodes raw data using the given codec and returns a newly constructed value.

Types

type Codec

type Codec interface {
	Marshal(v any) ([]byte, error)
	Unmarshal(data []byte, v any) error
}

Jump to

Keyboard shortcuts

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