codec

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 1 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetCodec

func SetCodec(c Codec)

SetCodec sets default codec instance

Types

type Codec

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

Codec is the interface that wraps the arpc Message data encoding method.

Marshal returns the JSON encoding of v

Unmarshal parses the Message data and stores the result in the value pointed to by v

var DefaultCodec Codec = &JSONCodec{}

DefaultCodec is the default codec used by arpc

type JSONCodec

type JSONCodec struct{}

JSONCodec wraps std json

func (*JSONCodec) Marshal

func (j *JSONCodec) Marshal(v interface{}) ([]byte, error)

Marshal wraps std json.Marshal

func (*JSONCodec) Unmarshal

func (j *JSONCodec) Unmarshal(data []byte, v interface{}) error

Unmarshal wraps std json.Unmarshal

Jump to

Keyboard shortcuts

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