codec

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShortRead = errors.New("decode from buffer: not all bytes were consumed")

Functions

func Decode

func Decode(buf []byte, value Decodable) error

Decode value from a byte buffer.

func DecodeByteSlice

func DecodeByteSlice(w io.Reader) ([]byte, int, error)

DecodeByteSlice decodes []string from a buffer.

func DecodeCompact16

func DecodeCompact16(w io.Reader) (uint16, int, error)

DecodeCompact16 decodes uint16 from a buffer.

func DecodeFrom

func DecodeFrom(r io.Reader, value Decodable) (int, error)

DecodeFrom decodes a value using data from a reader stream.

func DecodeSlice

func DecodeSlice[V any, H scale.DecodablePtr[V]](buf []byte) ([]V, error)

DecodeSlice decodes slice from a buffer.

func DecodeStringSlice

func DecodeStringSlice(w io.Reader) ([]string, int, error)

DecodeStringSlice decodes []string from a buffer.

func Encode

func Encode(value Encodable) ([]byte, error)

Encode value to a byte buffer.

func EncodeByteSlice

func EncodeByteSlice(w io.Writer, value []byte) (int, error)

EncodeByteSlice encodes []string to a buffer.

func EncodeCompact16

func EncodeCompact16(w io.Writer, value uint16) (int, error)

EncodeCompact16 encodes uint16 to a buffer.

func EncodeSlice

func EncodeSlice[V any, H scale.EncodablePtr[V]](value []V) ([]byte, error)

EncodeSlice encodes slice to a buffer.

func EncodeStringSlice

func EncodeStringSlice(w io.Writer, value []string) (int, error)

EncodeStringSlice encodes []string to a buffer.

func EncodeTo

func EncodeTo(w io.Writer, value Encodable) (int, error)

EncodeTo encodes value to a writer stream.

func MustDecode

func MustDecode(buf []byte, value Decodable)

func MustEncode

func MustEncode(value Encodable) []byte

Types

type Decodable

type Decodable = scale.Decodable

Decodable is an interface that must be implemented bya struct to be decoded.

type Encodable

type Encodable = scale.Encodable

Encodable is an interface that must be implemented by a struct to be encoded.

Jump to

Keyboard shortcuts

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