package codec

import "github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"

Index

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

Source Files

codec.go

Version
v4.2.1 (latest)
Published
Dec 5, 2023
Platform
linux/amd64
Imports
6 packages
Last checked
1 week ago

Tools for package owners.