common

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cp added in v1.1.0

func Cp(bz []byte) (ret []byte)

Returns a copy of the given byte slice.

func CpIncr added in v1.1.0

func CpIncr(bz []byte) (ret []byte)

Returns a slice of the same length (big endian) except incremented by one. Returns nil on overflow (e.g. if bz bytes are all 0xFF) CONTRACT: len(bz) > 0

func UnsafeBytesToStr added in v0.19.1

func UnsafeBytesToStr(b []byte) string

UnsafeBytesToStr is meant to make a zero allocation conversion from []byte -> string to speed up operations, it is not meant to be used generally, but for a specific pattern to delete keys from a map.

func UnsafeStrToBytes added in v0.19.1

func UnsafeStrToBytes(s string) []byte

UnsafeStrToBytes uses unsafe to convert string into byte array. Returned bytes must not be altered after this function is called as it will cause a segmentation fault.

Types

type HexBytes

type HexBytes []byte

The main purpose of HexBytes is to enable HEX-encoding for json/encoding.

func (HexBytes) Bytes

func (bz HexBytes) Bytes() []byte

Allow it to fulfill various interfaces in light-client, etc...

func (HexBytes) Format

func (bz HexBytes) Format(s fmt.State, verb rune)

func (HexBytes) Marshal

func (bz HexBytes) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility

func (HexBytes) MarshalJSON

func (bz HexBytes) MarshalJSON() ([]byte, error)

This is the point of Bytes.

func (HexBytes) String

func (bz HexBytes) String() string

func (*HexBytes) Unmarshal

func (bz *HexBytes) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility

func (*HexBytes) UnmarshalJSON

func (bz *HexBytes) UnmarshalJSON(data []byte) error

This is the point of Bytes.

Jump to

Keyboard shortcuts

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