codec

package
v2.0.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const CSVHeader = "Time,Update Time,Name,Unit,Value,String Value,Boolean Value,Data Value,Sum"

CSVHeader is the fixed header to support records with different value types

Variables

This section is empty.

Functions

func DecodeCBOR

func DecodeCBOR(b []byte) (senml.Pack, error)

DecodeCBOR takes a SenML pack in CBOR bytes and decodes it into a Pack

func DecodeCSV

func DecodeCSV(b []byte, options ...Option) (senml.Pack, error)

DecodeCSV takes a SenML pack in CSV bytes and decodes it into a Pack

func DecodeJSON

func DecodeJSON(b []byte) (senml.Pack, error)

DecodeJSON takes a SenML pack in JSON bytes and decodes it into a Pack

func DecodeXML

func DecodeXML(b []byte) (senml.Pack, error)

DecodeXML takes a SenML pack in XML bytes and decodes it into a Pack

func EncodeCBOR

func EncodeCBOR(p senml.Pack) ([]byte, error)

EncodeCBOR serializes the SenML pack into CBOR bytes

func EncodeCSV

func EncodeCSV(p senml.Pack, options ...Option) ([]byte, error)

EncodeCSV serializes the SenML pack into CSV bytes

func EncodeJSON

func EncodeJSON(p senml.Pack, options ...Option) ([]byte, error)

EncodeJSON serializes the SenML pack into JSON bytes

func EncodeXML

func EncodeXML(p senml.Pack, options ...Option) ([]byte, error)

EncodeXML serializes the SenML pack into XML bytes

func PrettyPrint

func PrettyPrint(o *Options)

PrettyPrint enables indentation of JSON and XML outputs

func ReadCSV

func ReadCSV(r io.Reader, options ...Option) (senml.Pack, error)

func WithHeader

func WithHeader(o *Options)

WithHeader enables CSV header

func WriteCSV

func WriteCSV(p senml.Pack, w io.Writer, options ...Option) error

Types

type Option

type Option func(*Options)

type Options

type Options struct {
	// PrettyPrint enables indentation of JSON and XML outputs
	PrettyPrint bool
	// WithHeader enables CSV header
	WithHeader bool
}

Jump to

Keyboard shortcuts

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