encoding

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package encoding provides encoding and decoding capabilities for different encodings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func I2OSP

func I2OSP(value, length int) []byte

I2OSP 32 bit Integer to Octet Stream Primitive on maximum 4 bytes.

func OS2IP

func OS2IP(input []byte) int

OS2IP Octet Stream to Integer Primitive on maximum 4 bytes / 32 bits.

Types

type Encoding

type Encoding byte

Encoding identifies referenced encoding formats.

const (

	// JSON encoding.
	JSON Encoding = 1 + iota

	// Gob encoding.
	Gob

	// MessagePack encoding.
	MessagePack

	// Default is the default encoding used when none specified.
	Default = JSON
)

func (Encoding) Available

func (e Encoding) Available() error

Available returns nil if the encoding is available, and an error if not.

func (Encoding) Decode

func (e Encoding) Decode(encoded []byte, receiver interface{}) (interface{}, error)

Decode returns the receiver struct filled with the decoding of the encoded input. Returns an error if it fails.

func (Encoding) Encode

func (e Encoding) Encode(v interface{}) ([]byte, error)

Encode returns the encoding of v in the receivers format.

func (Encoding) String

func (e Encoding) String() string

String implements the Stringer() interface.

Jump to

Keyboard shortcuts

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