codec

package
v1.2.18 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 1 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetCodec

func SetCodec(c Codec)

SetCodec replaces DefaultCodec.

Types

type Codec

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

Codec encodes and decodes the body of arpc Messages.

Marshal returns the encoding of v.

Unmarshal decodes data and stores the result in the value pointed to by v.

var DefaultCodec Codec = &JSONCodec{}

DefaultCodec is the codec used by arpc when none is specified.

type JSONCodec

type JSONCodec struct{}

JSONCodec is a Codec based on encoding/json.

func (*JSONCodec) Marshal

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

Marshal calls json.Marshal.

func (*JSONCodec) Unmarshal

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

Unmarshal calls json.Unmarshal.

Jump to

Keyboard shortcuts

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