tools

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Parsing/Encoding
	ErrEmptyString   = &toolsErr{"empty hex string"}
	ErrSyntax        = &toolsErr{"invalid hex string"}
	ErrMissingPrefix = &toolsErr{"hex string without 0x prefix"}
	ErrOddLength     = &toolsErr{"hex string of odd length"}
	ErrEmptyNumber   = &toolsErr{"hex string \"0x\""}
	ErrLeadingZero   = &toolsErr{"hex number with leading zero digits"}
	ErrUint64Range   = &toolsErr{"hex number > 64 bits"}
	ErrBig256Range   = &toolsErr{"hex number > 256 bits"}
)

Errors

Functions

func SmartMarshal

func SmartMarshal(inItem Marshaller, ioBuf []byte) []byte

SmartMarshal marshals the given item to the given buffer. If there is not enough space

func Zero

func Zero(buf []byte)

Zero zeros out a given slice

Types

type Buf

type Buf struct {
	Unmarshaller

	Bytes []byte
}

Buf is a flexible buffer designed for reuse.

func (*Buf) Unmarshal

func (buf *Buf) Unmarshal(inSrc []byte) error

Unmarshal effectively copies the src buffer.

type Bytes

type Bytes []byte

Bytes marshal/unmarshal as a JSON string with 0x prefix. The empty slice marshals as "0x".

func (Bytes) MarshalText

func (b Bytes) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (Bytes) String

func (b Bytes) String() string

String returns the hex encoding of b.

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(in []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Bytes) UnmarshalText

func (b *Bytes) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Marshaller

type Marshaller interface {
	Marshal() ([]byte, error)
	MarshalTo([]byte) (int, error)
	Size() int
}

Marshaller used to generalize serialization

type Unmarshaller

type Unmarshaller interface {
	Unmarshal([]byte) error
}

Unmarshaller used to generalize deserialization

Directories

Path Synopsis
Package ctx provides project-agnostic utility code for Go projects
Package ctx provides project-agnostic utility code for Go projects

Jump to

Keyboard shortcuts

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