codecs

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownCodec = errors.New("unknown codec")

ErrUnknownCodec is returned when no codec is found for the given name.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encode(any) ([]byte, error)
	Decode([]byte, any) error
	Name() string
}

Codec defines the interface for a two way conversion between Q and R.

func ForName added in v0.3.0

func ForName(name string) (Codec, error)

ForName returns the codec for the given name or ErrUnknownCodec if no codec is found.

type JSONCodec

type JSONCodec struct{}

JSONCodec is a Codec that uses JSON as the underlying format.

func (JSONCodec) Decode

func (c JSONCodec) Decode(b []byte, r any) error

func (JSONCodec) Encode

func (c JSONCodec) Encode(q any) ([]byte, error)

func (JSONCodec) Name added in v0.3.0

func (c JSONCodec) Name() string

type TOMLCodec

type TOMLCodec struct{}

TOMLCodec is a Codec that uses TOML as the underlying format.

func (TOMLCodec) Decode

func (c TOMLCodec) Decode(b []byte, r any) error

func (TOMLCodec) Encode

func (c TOMLCodec) Encode(q any) ([]byte, error)

func (TOMLCodec) Name added in v0.3.0

func (c TOMLCodec) Name() string

Jump to

Keyboard shortcuts

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