codec

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package codec

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(serializationType string, body interface{}) ([]byte, error)

func RegisterSerializer

func RegisterSerializer(serializationType string, s Serializer)

func Unmarshal

func Unmarshal(serializationType string, in []byte, body interface{}) error

Types

type JSONSerialization

type JSONSerialization struct{}

func (*JSONSerialization) Marshal

func (s *JSONSerialization) Marshal(body interface{}) ([]byte, error)

func (*JSONSerialization) Unmarshal

func (s *JSONSerialization) Unmarshal(in []byte, body interface{}) error

type ProtobufSerialization

type ProtobufSerialization struct{}

func (*ProtobufSerialization) Marshal

func (p *ProtobufSerialization) Marshal(body interface{}) (out []byte, err error)

func (*ProtobufSerialization) Unmarshal

func (p *ProtobufSerialization) Unmarshal(in []byte, body interface{}) error

type Serializer

type Serializer interface {
	Unmarshal(in []byte, body interface{}) error
	Marshal(body interface{}) (out []byte, err error)
}

func GetSerializer

func GetSerializer(serializationType string) Serializer

Jump to

Keyboard shortcuts

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