codec

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MPL-2.0 Imports: 6 Imported by: 11

Documentation

Overview

* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var ErrIrregularData = errors.New("irregular data")
View Source
var ErrTooLarge = errors.New("bytes.Buffer: too large")

Functions

func BytesLEToUint16 added in v0.1.13

func BytesLEToUint16(data []byte) uint16

func BytesLEToUint32 added in v0.1.13

func BytesLEToUint32(data []byte) uint32

func BytesLEToUint64 added in v0.1.13

func BytesLEToUint64(data []byte) uint64

func SafeAdd

func SafeAdd(x, y uint64) (uint64, bool)

func SerializeToBytes

func SerializeToBytes(values ...Serializable) []byte

func Uint16ToBytesLE added in v0.1.13

func Uint16ToBytesLE(val uint16) []byte

func Uint32ToBytesLE added in v0.1.13

func Uint32ToBytesLE(val uint32) []byte

func Uint64ToBytesLE added in v0.1.13

func Uint64ToBytesLE(val uint64) []byte

Types

type Serializable

type Serializable interface {
	Serialization(sink *ZeroCopySink)
}

type ZeroCopyReader added in v0.1.12

type ZeroCopyReader struct {
	Source *ZeroCopySource
	// contains filtered or unexported fields
}

func NewZeroCopyReader added in v0.1.12

func NewZeroCopyReader(b []byte) *ZeroCopyReader

func (*ZeroCopyReader) BackUp added in v0.1.12

func (self *ZeroCopyReader) BackUp(n uint64)

Backs up a number of bytes, so that the next call to NextXXX() returns data again that was already returned by the last call to NextXXX().

func (*ZeroCopyReader) Error added in v0.1.12

func (self *ZeroCopyReader) Error() error

func (*ZeroCopyReader) Len added in v0.1.12

func (self *ZeroCopyReader) Len() uint64

Len returns the number of bytes of the unread portion of the slice.

func (*ZeroCopyReader) Pos added in v0.1.12

func (self *ZeroCopyReader) Pos() uint64

func (*ZeroCopyReader) ReadAddress added in v0.1.12

func (self *ZeroCopyReader) ReadAddress() (addr web3.Address)

func (*ZeroCopyReader) ReadBool added in v0.1.12

func (self *ZeroCopyReader) ReadBool() (data bool)

func (*ZeroCopyReader) ReadBytes added in v0.1.12

func (self *ZeroCopyReader) ReadBytes(n uint64) (data []byte)

Read implements the io.ZeroCopyReader interface.

func (*ZeroCopyReader) ReadHash added in v0.1.12

func (self *ZeroCopyReader) ReadHash() (hash web3.Hash)

func (*ZeroCopyReader) ReadInt32 added in v0.1.12

func (self *ZeroCopyReader) ReadInt32() (data int32)

func (*ZeroCopyReader) ReadInt64 added in v0.1.12

func (self *ZeroCopyReader) ReadInt64() (data int64)

func (*ZeroCopyReader) ReadString added in v0.1.12

func (self *ZeroCopyReader) ReadString() (data string)

func (*ZeroCopyReader) ReadUint32 added in v0.1.12

func (self *ZeroCopyReader) ReadUint32() (data uint32)

func (*ZeroCopyReader) ReadUint32BE added in v0.1.12

func (self *ZeroCopyReader) ReadUint32BE() (data uint32)

func (*ZeroCopyReader) ReadUint64 added in v0.1.12

func (self *ZeroCopyReader) ReadUint64() (data uint64)

func (*ZeroCopyReader) ReadUint64BE added in v0.1.12

func (self *ZeroCopyReader) ReadUint64BE() (data uint64)

func (*ZeroCopyReader) ReadUint8 added in v0.1.12

func (self *ZeroCopyReader) ReadUint8() (data uint8)

func (*ZeroCopyReader) ReadVarBytes added in v0.1.12

func (self *ZeroCopyReader) ReadVarBytes() (data []byte)

func (*ZeroCopyReader) ReadVarUint added in v0.1.12

func (self *ZeroCopyReader) ReadVarUint() (data uint64)

func (*ZeroCopyReader) Size added in v0.1.12

func (self *ZeroCopyReader) Size() uint64

Size returns the original length of the underlying byte slice. Size is the number of bytes available for reading via ReadAt. The returned value is always the same and is not affected by calls to any other method.

func (*ZeroCopyReader) Skip added in v0.1.12

func (self *ZeroCopyReader) Skip(n uint64)

type ZeroCopySink

type ZeroCopySink struct {
	// contains filtered or unexported fields
}

func NewZeroCopySink

func NewZeroCopySink(b []byte) *ZeroCopySink

NewReader returns a new ZeroCopySink reading from b.

func (*ZeroCopySink) BackUp

func (self *ZeroCopySink) BackUp(n uint64)

Backs up a number of bytes, so that the next call to NextXXX() returns data again that was already returned by the last call to NextXXX().

func (*ZeroCopySink) Bytes

func (self *ZeroCopySink) Bytes() []byte

func (*ZeroCopySink) NextBytes

func (self *ZeroCopySink) NextBytes(n uint64) (data []byte)

func (*ZeroCopySink) Reset

func (self *ZeroCopySink) Reset()

func (*ZeroCopySink) Size

func (self *ZeroCopySink) Size() uint64

func (*ZeroCopySink) WriteAddress

func (self *ZeroCopySink) WriteAddress(addr web3.Address) *ZeroCopySink

func (*ZeroCopySink) WriteBool

func (self *ZeroCopySink) WriteBool(data bool) *ZeroCopySink

func (*ZeroCopySink) WriteByte

func (self *ZeroCopySink) WriteByte(c byte) *ZeroCopySink

func (*ZeroCopySink) WriteBytes

func (self *ZeroCopySink) WriteBytes(p []byte) *ZeroCopySink

func (*ZeroCopySink) WriteHash

func (self *ZeroCopySink) WriteHash(hash web3.Hash) *ZeroCopySink

func (*ZeroCopySink) WriteInt16

func (self *ZeroCopySink) WriteInt16(data int16) *ZeroCopySink

func (*ZeroCopySink) WriteInt16BE added in v0.1.8

func (self *ZeroCopySink) WriteInt16BE(data int16) *ZeroCopySink

func (*ZeroCopySink) WriteInt32

func (self *ZeroCopySink) WriteInt32(data int32) *ZeroCopySink

func (*ZeroCopySink) WriteInt32BE added in v0.1.8

func (self *ZeroCopySink) WriteInt32BE(data int32) *ZeroCopySink

func (*ZeroCopySink) WriteInt64

func (self *ZeroCopySink) WriteInt64(data int64) *ZeroCopySink

func (*ZeroCopySink) WriteInt64BE added in v0.1.8

func (self *ZeroCopySink) WriteInt64BE(data int64) *ZeroCopySink

func (*ZeroCopySink) WriteString

func (self *ZeroCopySink) WriteString(data string) (size uint64)

func (*ZeroCopySink) WriteUint16

func (self *ZeroCopySink) WriteUint16(data uint16) *ZeroCopySink

func (*ZeroCopySink) WriteUint16BE added in v0.1.8

func (self *ZeroCopySink) WriteUint16BE(data uint16) *ZeroCopySink

func (*ZeroCopySink) WriteUint32

func (self *ZeroCopySink) WriteUint32(data uint32) *ZeroCopySink

func (*ZeroCopySink) WriteUint32BE added in v0.1.8

func (self *ZeroCopySink) WriteUint32BE(data uint32) *ZeroCopySink

func (*ZeroCopySink) WriteUint64

func (self *ZeroCopySink) WriteUint64(data uint64) *ZeroCopySink

func (*ZeroCopySink) WriteUint64BE added in v0.1.8

func (self *ZeroCopySink) WriteUint64BE(data uint64) *ZeroCopySink

func (*ZeroCopySink) WriteUint8

func (self *ZeroCopySink) WriteUint8(data uint8) *ZeroCopySink

func (*ZeroCopySink) WriteVarBytes

func (self *ZeroCopySink) WriteVarBytes(data []byte) (size uint64)

func (*ZeroCopySink) WriteVarUint

func (self *ZeroCopySink) WriteVarUint(data uint64) (size uint64)

type ZeroCopySource

type ZeroCopySource struct {
	// contains filtered or unexported fields
}

func NewZeroCopySource

func NewZeroCopySource(b []byte) *ZeroCopySource

NewReader returns a new ZeroCopySource reading from b.

func (*ZeroCopySource) BackUp

func (self *ZeroCopySource) BackUp(n uint64)

Backs up a number of bytes, so that the next call to NextXXX() returns data again that was already returned by the last call to NextXXX().

func (*ZeroCopySource) Len

func (self *ZeroCopySource) Len() uint64

Len returns the number of bytes of the unread portion of the slice.

func (*ZeroCopySource) NextAddress

func (self *ZeroCopySource) NextAddress() (data web3.Address, eof bool)

func (*ZeroCopySource) NextBool

func (self *ZeroCopySource) NextBool() (data bool, irregular bool, eof bool)

func (*ZeroCopySource) NextByte

func (self *ZeroCopySource) NextByte() (data byte, eof bool)

ReadByte implements the io.ByteReader interface.

func (*ZeroCopySource) NextBytes

func (self *ZeroCopySource) NextBytes(n uint64) (data []byte, eof bool)

Read implements the io.ZeroCopySource interface.

func (*ZeroCopySource) NextHash

func (self *ZeroCopySource) NextHash() (data web3.Hash, eof bool)

func (*ZeroCopySource) NextInt16

func (self *ZeroCopySource) NextInt16() (data int16, eof bool)

func (*ZeroCopySource) NextInt32

func (self *ZeroCopySource) NextInt32() (data int32, eof bool)

func (*ZeroCopySource) NextInt64

func (self *ZeroCopySource) NextInt64() (data int64, eof bool)

func (*ZeroCopySource) NextString

func (self *ZeroCopySource) NextString() (data string, size uint64, irregular bool, eof bool)

func (*ZeroCopySource) NextUint16

func (self *ZeroCopySource) NextUint16() (data uint16, eof bool)

func (*ZeroCopySource) NextUint32

func (self *ZeroCopySource) NextUint32() (data uint32, eof bool)

func (*ZeroCopySource) NextUint64

func (self *ZeroCopySource) NextUint64() (data uint64, eof bool)

func (*ZeroCopySource) NextUint8

func (self *ZeroCopySource) NextUint8() (data uint8, eof bool)

func (*ZeroCopySource) NextVarBytes

func (self *ZeroCopySource) NextVarBytes() (data []byte, size uint64, irregular bool, eof bool)

func (*ZeroCopySource) NextVarUint

func (self *ZeroCopySource) NextVarUint() (data uint64, size uint64, irregular bool, eof bool)

func (*ZeroCopySource) Pos

func (self *ZeroCopySource) Pos() uint64

func (*ZeroCopySource) ReadAddress added in v0.1.10

func (self *ZeroCopySource) ReadAddress() (web3.Address, error)

func (*ZeroCopySource) ReadBool added in v0.1.12

func (self *ZeroCopySource) ReadBool() (data bool, err error)

func (*ZeroCopySource) ReadByte added in v0.1.12

func (self *ZeroCopySource) ReadByte() (data byte, err error)

func (*ZeroCopySource) ReadBytes added in v0.1.12

func (self *ZeroCopySource) ReadBytes(n uint64) (data []byte, err error)

func (*ZeroCopySource) ReadHash added in v0.1.10

func (self *ZeroCopySource) ReadHash() (web3.Hash, error)

func (*ZeroCopySource) ReadString

func (self *ZeroCopySource) ReadString() (string, error)

func (*ZeroCopySource) ReadUint32

func (self *ZeroCopySource) ReadUint32() (data uint32, err error)

func (*ZeroCopySource) ReadUint32BE added in v0.1.8

func (self *ZeroCopySource) ReadUint32BE() (data uint32, err error)

func (*ZeroCopySource) ReadUint64 added in v0.1.2

func (self *ZeroCopySource) ReadUint64() (data uint64, err error)

func (*ZeroCopySource) ReadUint64BE added in v0.1.8

func (self *ZeroCopySource) ReadUint64BE() (data uint64, err error)

func (*ZeroCopySource) ReadUint8 added in v0.1.12

func (self *ZeroCopySource) ReadUint8() (data uint8, err error)

func (*ZeroCopySource) ReadVarBytes

func (self *ZeroCopySource) ReadVarBytes() (data []byte, err error)

func (*ZeroCopySource) ReadVarUint added in v0.1.12

func (self *ZeroCopySource) ReadVarUint() (data uint64, err error)

func (*ZeroCopySource) Reader added in v0.1.12

func (self *ZeroCopySource) Reader() *ZeroCopyReader

func (*ZeroCopySource) Size

func (self *ZeroCopySource) Size() uint64

Size returns the original length of the underlying byte slice. Size is the number of bytes available for reading via ReadAt. The returned value is always the same and is not affected by calls to any other method.

func (*ZeroCopySource) Skip

func (self *ZeroCopySource) Skip(n uint64) (eof bool)

Jump to

Keyboard shortcuts

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