coding

package
v0.0.0-...-e537141 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Decode(io.Reader, interface{}) error
}

type Encoder

type Encoder interface {
	Encode(io.Writer, interface{}) error
}

type MultiService

type MultiService struct {
	// contains filtered or unexported fields
}

MultiService houses a set of encoders and decoders and tries to dispatches Encode and Decode operations to them. Fot these operations it sets up a temporary bytes buffer so reads and writes are cached into the buffer so a failure in Decode and Encode call does not change the state of the Reader or Writer object.

func NewMultiService

func NewMultiService(enc []Encoder, dec []Decoder, pool pool.OfBytes) (m MultiService)

func (MultiService) Decode

func (m MultiService) Decode(r io.Reader, v interface{}) (err error)
Decode loops through the encoders and attempts to

calls their Encode method. If it succeeds it breaks the loop, if not it tries the next one.

func (MultiService) Encode

func (m MultiService) Encode(w io.Writer, v interface{}) (err error)
Encode loops through the encoders and attempts to

calls their Encode method. If it succeeds it breaks the loop, if not it tries the next one.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(enc Encoder, dec Decoder) (s Service)

func (Service) Decode

func (s Service) Decode(r io.Reader, v interface{}) (err error)

func (Service) Enccode

func (s Service) Enccode(w io.Writer, v interface{}) (err error)

type StdJsonCoder

type StdJsonCoder struct{}
StdJsonEncoder implements the Encoder and Decoder interface using

the standard library's Encoder and Decoder

func NewJsonService

func NewJsonService() (s StdJsonCoder)

func (StdJsonCoder) Decode

func (StdJsonCoder) Decode(r io.Reader, v interface{}) (err error)

func (StdJsonCoder) Encode

func (StdJsonCoder) Encode(w io.Writer, v interface{}) (err error)

Jump to

Keyboard shortcuts

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