codec

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package codec provides the interface definitions for encoding types into their byte slice representation, and decoding a byte slice into types.

Package json provides a JSON codec with an encoder/decoder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encoder
	Decoder
}

Codec is a composite of Encoder and Decoder.

type Decoder

type Decoder interface {
	// Decode decodes a byte slice representation into its Go type.
	Decode(in []byte, out any) error
}

Decoder decodes a byte slice representation into its Go type.

func RecordDecodedBytes

func RecordDecodedBytes(d Decoder, m metric.Int64Counter) Decoder

RecordDecodedBytes decorates a decoder with a metric that records the bytes that have been decoded.

type Encoder

type Encoder interface {
	// Encode encodes a type into its byte slice representation.
	Encode(in any) ([]byte, error)
}

Encoder encodes a type into its byte slice representation.

func RecordEncodedBytes

func RecordEncodedBytes(e Encoder, m metric.Int64Counter) Encoder

RecordEncodedBytes decorates an encoder with a metric that records the bytes that have been encoded.

type JSON

type JSON struct{}

JSON wraps the standard json library.

func (JSON) Decode

func (j JSON) Decode(in []byte, out any) error

Decode decodes a JSON-encoded byte slice into its type.

func (JSON) Encode

func (j JSON) Encode(in any) ([]byte, error)

Encode encodes a type into the JSON byte slice representation.

type VTProto

type VTProto struct{}

VTProto is a composite of Encoder and Decoder

func (VTProto) Decode

func (v VTProto) Decode(in []byte, out any) error

Decode decodes a byte slice into vtprotoMessage type.

func (VTProto) Encode

func (v VTProto) Encode(in any) ([]byte, error)

Encode encodes vtprotoMessage type into byte slice

Jump to

Keyboard shortcuts

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