convert

package
v0.0.0-...-8fe6f98 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package convert for transforming between json serialized []byte and go structs

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnableToConvertNilToStruct - nil cannot be converted to struct
	ErrUnableToConvertNilToStruct = errors.New(`unable to convert nil to [struct,array,slice,ptr]`)
	// ErrUnableToConvertValueToStruct - value  cannot be converted to struct
	ErrUnableToConvertValueToStruct = errors.New(`unable to convert value to [struct,array,slice,ptr]`)
)

Functions

func ArgsToBytes

func ArgsToBytes(iargs ...interface{}) (aa [][]byte, err error)

ArgsToBytes converts func arguments to bytes

func FromBytes

func FromBytes(bb []byte, target interface{}) (result interface{}, err error)

FromBytes converts []byte to target interface

func FromBytesToStruct

func FromBytesToStruct(bb []byte, target interface{}) (result interface{}, err error)

FromBytesToStruct converts []byte to struct,array,slice depending on target type

func FromResponse

func FromResponse(response peer.Response, target interface{}) (result interface{}, err error)

FromResponse converts response.Payload to target

func ToBytes

func ToBytes(value interface{}) ([]byte, error)

ToBytes converts inteface{} (string, []byte , struct to ToByter interface to []byte for storing in state

func UnmarshallPtr

func UnmarshallPtr(bb []byte, targetPtr interface{}) (result interface{}, err error)

UnmarshallPtr unmarshalls [] byte to pointer, and returns value pointed to

Types

type FromByter

type FromByter interface {
	FromBytes([]byte) (interface{}, error)
}

FromByter interface supports FromBytes func for converting to structure

type ToByter

type ToByter interface {
	ToBytes() ([]byte, error)
}

ToByter interface supports ToBytes func, marshalling to []byte (json.Marshall)

Jump to

Keyboard shortcuts

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