wrappers

package
v1.6.5-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: BSD-3-Clause Imports: 8 Imported by: 338

Documentation

Index

Constants

View Source
const (
	MaxStringLen = math.MaxUint16

	// ByteLen is the number of bytes per byte...
	ByteLen = 1
	// ShortLen is the number of bytes per short
	ShortLen = 2
	// IntLen is the number of bytes per int
	IntLen = 4
	// LongLen is the number of bytes per long
	LongLen = 8
	// BoolLen is the number of bytes per bool
	BoolLen = 1
	// IPLen is the number of bytes per IP
	IPLen = 16 + ShortLen
)

Variables

This section is empty.

Functions

func TryPack2DBytes added in v0.8.0

func TryPack2DBytes(packer *Packer, valIntf interface{})

TryPack2DBytes attempts to pack the value as a 2D byte slice

func TryPackAddr

func TryPackAddr(packer *Packer, valIntf interface{})

TryPackAddr attempts to pack the value as a 20-byte sequence

func TryPackAddrList

func TryPackAddrList(packer *Packer, valIntf interface{})

TryPackAddrList attempts to pack the value as a list of 20-byte sequences

func TryPackByte

func TryPackByte(packer *Packer, valIntf interface{})

TryPackByte attempts to pack the value as a byte

func TryPackBytes

func TryPackBytes(packer *Packer, valIntf interface{})

TryPackBytes attempts to pack the value as a list of bytes

func TryPackHash

func TryPackHash(packer *Packer, valIntf interface{})

TryPackHash attempts to pack the value as a 32-byte sequence

func TryPackHashes

func TryPackHashes(packer *Packer, valIntf interface{})

TryPackHashes attempts to pack the value as a list of 32-byte sequences

func TryPackIP

func TryPackIP(packer *Packer, valIntf interface{})

TryPackIP attempts to pack the value as an ip port pair

func TryPackIPCert added in v1.4.0

func TryPackIPCert(packer *Packer, valIntf interface{})

func TryPackIPCertList added in v1.4.0

func TryPackIPCertList(packer *Packer, valIntf interface{})

func TryPackIPList

func TryPackIPList(packer *Packer, valIntf interface{})

TryPackIPList attempts to pack the value as an ip port pair list

func TryPackInt

func TryPackInt(packer *Packer, valIntf interface{})

TryPackInt attempts to pack the value as an int

func TryPackLong

func TryPackLong(packer *Packer, valIntf interface{})

TryPackLong attempts to pack the value as a long

func TryPackShort

func TryPackShort(packer *Packer, valIntf interface{})

TryPackShort attempts to pack the value as a short

func TryPackStr

func TryPackStr(packer *Packer, valIntf interface{})

TryPackStr attempts to pack the value as a string

func TryPackX509Certificate added in v1.4.0

func TryPackX509Certificate(packer *Packer, valIntf interface{})

func TryUnpack2DBytes added in v0.8.0

func TryUnpack2DBytes(packer *Packer) interface{}

TryUnpack2DBytes attempts to unpack the value as a 2D byte slice

func TryUnpackAddr

func TryUnpackAddr(packer *Packer) interface{}

TryUnpackAddr attempts to unpack the value as a 20-byte sequence

func TryUnpackAddrList

func TryUnpackAddrList(packer *Packer) interface{}

TryUnpackAddrList attempts to unpack the value as a list of 20-byte sequences

func TryUnpackByte

func TryUnpackByte(packer *Packer) interface{}

TryUnpackByte attempts to unpack a value as a byte

func TryUnpackBytes

func TryUnpackBytes(packer *Packer) interface{}

TryUnpackBytes attempts to unpack the value as a list of bytes

func TryUnpackHash

func TryUnpackHash(packer *Packer) interface{}

TryUnpackHash attempts to unpack the value as a 32-byte sequence

func TryUnpackHashes

func TryUnpackHashes(packer *Packer) interface{}

TryUnpackHashes attempts to unpack the value as a list of 32-byte sequences

func TryUnpackIP

func TryUnpackIP(packer *Packer) interface{}

TryUnpackIP attempts to unpack the value as an ip port pair

func TryUnpackIPCert added in v1.4.0

func TryUnpackIPCert(packer *Packer) interface{}

func TryUnpackIPCertList added in v1.4.0

func TryUnpackIPCertList(packer *Packer) interface{}

func TryUnpackIPList

func TryUnpackIPList(packer *Packer) interface{}

TryUnpackIPList attempts to unpack the value as an ip port pair list

func TryUnpackInt

func TryUnpackInt(packer *Packer) interface{}

TryUnpackInt attempts to unpack a value as an int

func TryUnpackLong

func TryUnpackLong(packer *Packer) interface{}

TryUnpackLong attempts to unpack a value as a long

func TryUnpackShort

func TryUnpackShort(packer *Packer) interface{}

TryUnpackShort attempts to unpack a value as a short

func TryUnpackStr

func TryUnpackStr(packer *Packer) interface{}

TryUnpackStr attempts to unpack the value as a string

func TryUnpackX509Certificate added in v1.4.0

func TryUnpackX509Certificate(packer *Packer) interface{}

Types

type Closer added in v1.4.5

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

Closer is a nice utility for closing a group of objects while reporting an error if one occurs.

func (*Closer) Add added in v1.4.5

func (c *Closer) Add(closer io.Closer)

Add a new object to be closed.

func (*Closer) Close added in v1.4.5

func (c *Closer) Close() error

Close closes each of the closers add to [c] and returns the first error

that occurs or nil if no error occurs.

type Errs

type Errs struct{ Err error }

func (*Errs) Add

func (errs *Errs) Add(errors ...error)

func (*Errs) Errored

func (errs *Errs) Errored() bool

type Packer

type Packer struct {
	Errs

	// The largest allowed size of expanding the byte array
	MaxSize int
	// The current byte array
	Bytes []byte
	// The offset that is being written to in the byte array
	Offset int
}

Packer packs and unpacks a byte array from/to standard values

func (*Packer) CheckSpace

func (p *Packer) CheckSpace(bytes int)

CheckSpace requires that there is at least bytes of write space left in the byte array. If this is not true, an error is added to the packer

func (*Packer) Expand

func (p *Packer) Expand(bytes int)

Expand ensures that there is bytes bytes left of space in the byte slice. If this is not allowed due to the maximum size, an error is added to the packer In order to understand this code, its important to understand the difference between a slice's length and its capacity.

func (*Packer) Pack2DByteSlice added in v0.8.0

func (p *Packer) Pack2DByteSlice(byteSlices [][]byte)

Pack2DByteSlice append a 2D byte slice to the byte array

func (*Packer) PackBool

func (p *Packer) PackBool(b bool)

PackBool packs a bool into the byte array

func (*Packer) PackByte

func (p *Packer) PackByte(val byte)

PackByte append a byte to the byte array

func (*Packer) PackBytes

func (p *Packer) PackBytes(bytes []byte)

PackBytes append a byte slice to the byte array

func (*Packer) PackFixedByteSlices

func (p *Packer) PackFixedByteSlices(byteSlices [][]byte)

PackFixedByteSlices append a byte slice slice to the byte array

func (*Packer) PackFixedBytes

func (p *Packer) PackFixedBytes(bytes []byte)

PackFixedBytes append a byte slice, with no length descriptor to the byte array

func (*Packer) PackIP

func (p *Packer) PackIP(ip utils.IPDesc)

PackIP packs an ip port pair to the byte array

func (*Packer) PackIPCert added in v1.4.0

func (p *Packer) PackIPCert(ipCert utils.IPCertDesc)

func (*Packer) PackIPs

func (p *Packer) PackIPs(ips []utils.IPDesc)

PackIPs unpacks an ip port pair slice from the byte array

func (*Packer) PackInt

func (p *Packer) PackInt(val uint32)

PackInt append an int to the byte array

func (*Packer) PackLong

func (p *Packer) PackLong(val uint64)

PackLong append a long to the byte array

func (*Packer) PackShort

func (p *Packer) PackShort(val uint16)

PackShort append a short to the byte array

func (*Packer) PackStr

func (p *Packer) PackStr(str string)

PackStr append a string to the byte array

func (*Packer) PackX509Certificate added in v1.4.0

func (p *Packer) PackX509Certificate(cert *x509.Certificate)

func (*Packer) Unpack2DByteSlice added in v0.8.0

func (p *Packer) Unpack2DByteSlice() [][]byte

Unpack2DByteSlice returns a 2D byte slice from the byte array.

func (*Packer) UnpackBool

func (p *Packer) UnpackBool() bool

UnpackBool unpacks a bool from the byte array

func (*Packer) UnpackByte

func (p *Packer) UnpackByte() byte

UnpackByte unpack a byte from the byte array

func (*Packer) UnpackBytes

func (p *Packer) UnpackBytes() []byte

UnpackBytes unpack a byte slice from the byte array

func (*Packer) UnpackFixedByteSlices

func (p *Packer) UnpackFixedByteSlices(size int) [][]byte

UnpackFixedByteSlices returns a byte slice slice from the byte array. Each byte slice has the specified size. The number of byte slices is read from the byte array.

func (*Packer) UnpackFixedBytes

func (p *Packer) UnpackFixedBytes(size int) []byte

UnpackFixedBytes unpack a byte slice, with no length descriptor from the byte array

func (*Packer) UnpackIP

func (p *Packer) UnpackIP() utils.IPDesc

UnpackIP unpacks an ip port pair from the byte array

func (*Packer) UnpackIPCert added in v1.4.0

func (p *Packer) UnpackIPCert() utils.IPCertDesc

func (*Packer) UnpackIPs

func (p *Packer) UnpackIPs() []utils.IPDesc

UnpackIPs unpacks an ip port pair slice from the byte array

func (*Packer) UnpackInt

func (p *Packer) UnpackInt() uint32

UnpackInt unpack an int from the byte array

func (*Packer) UnpackLong

func (p *Packer) UnpackLong() uint64

UnpackLong unpack a long from the byte array

func (*Packer) UnpackShort

func (p *Packer) UnpackShort() uint16

UnpackShort unpack a short from the byte array

func (*Packer) UnpackStr

func (p *Packer) UnpackStr() string

UnpackStr unpacks a string from the byte array

func (*Packer) UnpackX509Certificate added in v1.4.0

func (p *Packer) UnpackX509Certificate() *x509.Certificate

Jump to

Keyboard shortcuts

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