codec

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(bz []byte, target interface{}) error

Decode decodes `bz` with the scale codec into `target`. `target` should be a pointer.

func DecodeFromHex

func DecodeFromHex(str string, target interface{}) error

DecodeFromHex decodes `str` with the scale codec into `target`. `target` should be a pointer.

func Encode

func Encode(value interface{}) ([]byte, error)

Encode encodes `value` with the scale codec with passed EncoderOptions, returning []byte

func EncodeToHex

func EncodeToHex(value interface{}) (string, error)

EncodeToHex encodes `value` with the scale codec, returning a hex string (prefixed by 0x)

func EncodedLength

func EncodedLength(value interface{}) (int, error)

EncodedLength returns the length of the value when encoded as a byte array

func Eq

func Eq(one, other interface{}) bool

Eq compares the value of the input to see if there is a match

func Hex

func Hex(value interface{}) (string, error)

Hex returns a hex string representation of the value (not of the encoded value)

func HexDecodeString

func HexDecodeString(s string) ([]byte, error)

HexDecodeString decodes bytes from a hex string. Contrary to hex.DecodeString, this function does not error if "0x" is prefixed, and adds an extra 0 if the hex string has an odd length.

func HexEncodeToString

func HexEncodeToString(b []byte) string

HexEncodeToString encodes bytes to a hex string. Contrary to hex.EncodeToString, this function prefixes the hex string with "0x"

func MustHexDecodeString

func MustHexDecodeString(str string) []byte

MustHexDecodeString panics if str cannot be decoded

Types

type Hexer

type Hexer interface {
	Hex() string
}

Hexer interface is implemented by any type that has a Hex() function returning a string

Jump to

Keyboard shortcuts

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