bytebuf

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MIT Imports: 5 Imported by: 3

README

Byte buffers

Collection of various byte buffer implementations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccumulativeBufToBytes

func AccumulativeBufToBytes(dst []byte, val interface{}) ([]byte, error)

AccumulativeBufToBytes registers x2bytes conversion function accepts AccumulativeBuf.

func ChainBufToBytes

func ChainBufToBytes(dst []byte, val interface{}) ([]byte, error)

ChainBufToBytes registers x2bytes conversion function accepts ChainBuf.

Types

type AccumulativeBuf

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

AccumulativeBuf is a wrapper around ChainBuf that allows to accumulate buffer data and use only necessary part.

See StakeOut and Staked* methods.

func (*AccumulativeBuf) Bytes

func (b *AccumulativeBuf) Bytes() []byte

Bytes returns contents of the buffer.

func (*AccumulativeBuf) BytesCopy

func (b *AccumulativeBuf) BytesCopy() []byte

BytesCopy returns copy of buffer contents.

func (*AccumulativeBuf) Cap

func (b *AccumulativeBuf) Cap() int

func (AccumulativeBuf) Error

func (b AccumulativeBuf) Error() error

Get last error caught in Write* methods.

func (*AccumulativeBuf) Grow

func (b *AccumulativeBuf) Grow(newLen int) *AccumulativeBuf

Grow increases length of the buffer.

func (*AccumulativeBuf) GrowDelta

func (b *AccumulativeBuf) GrowDelta(delta int) *AccumulativeBuf

GrowDelta increases length of the buffer to actual length + delta.

See Grow().

func (*AccumulativeBuf) Len

func (b *AccumulativeBuf) Len() int

func (*AccumulativeBuf) RangeBytes

func (b *AccumulativeBuf) RangeBytes(off, len int) []byte

RangeBytes returns buffer bytes from offset off with length len.

func (*AccumulativeBuf) RangeBytesCopy

func (b *AccumulativeBuf) RangeBytesCopy(off, len int) []byte

RangeBytesCopy copies result of RangeBytes().

func (*AccumulativeBuf) RangeString

func (b *AccumulativeBuf) RangeString(off, len int) string

RangeString returns buffer bytes as string from offset off with length len.

func (*AccumulativeBuf) RangeStringCopy

func (b *AccumulativeBuf) RangeStringCopy(off, len int) string

RangeStringCopy copies result of RangeString().

func (*AccumulativeBuf) Replace

func (b *AccumulativeBuf) Replace(old, new []byte, n int) *AccumulativeBuf

Replace replaces old bytes to new in buffer.

func (*AccumulativeBuf) ReplaceAll

func (b *AccumulativeBuf) ReplaceAll(old, new []byte) *AccumulativeBuf

ReplaceAll replace all occurrences of old bytes to new in buffer.

func (*AccumulativeBuf) ReplaceStr

func (b *AccumulativeBuf) ReplaceStr(old, new string, n int) *AccumulativeBuf

ReplaceStr replace old to new substrings in buffer.

func (*AccumulativeBuf) ReplaceStrAll

func (b *AccumulativeBuf) ReplaceStrAll(old, new string) *AccumulativeBuf

ReplaceStrAll replaces all occurrences of old substrings to new in buffer.

func (*AccumulativeBuf) Reset

func (b *AccumulativeBuf) Reset() *AccumulativeBuf

func (*AccumulativeBuf) StakeOut

func (b *AccumulativeBuf) StakeOut() *AccumulativeBuf

StakeOut saves current offset for further use.

func (*AccumulativeBuf) StakedBytes

func (b *AccumulativeBuf) StakedBytes() []byte

StakedBytes returns accumulated bytes from staked offset.

func (*AccumulativeBuf) StakedBytesCopy

func (b *AccumulativeBuf) StakedBytesCopy() []byte

StakedBytesCopy returns copy of accumulated bytes since staked offset.

func (*AccumulativeBuf) StakedLen

func (b *AccumulativeBuf) StakedLen() int

StakedLen returns length of accumulated bytes since staked offset.

func (*AccumulativeBuf) StakedOffset

func (b *AccumulativeBuf) StakedOffset() int

StakedOffset returns staked offset.

func (*AccumulativeBuf) StakedString

func (b *AccumulativeBuf) StakedString() string

StakedString returns accumulated bytes as string.

func (*AccumulativeBuf) StakedStringCopy

func (b *AccumulativeBuf) StakedStringCopy() string

StakedStringCopy returns copy of accumulated bytes as string.

func (*AccumulativeBuf) String

func (b *AccumulativeBuf) String() string

Get contents of the buffer as string.

func (*AccumulativeBuf) StringCopy

func (b *AccumulativeBuf) StringCopy() string

StringCopy returns copy of the buffer contents as string.

func (*AccumulativeBuf) Write

func (b *AccumulativeBuf) Write(p []byte) *AccumulativeBuf

Write bytes to the buffer.

func (*AccumulativeBuf) WriteApplyFn added in v1.0.2

func (b *AccumulativeBuf) WriteApplyFn(p []byte, fn func(dst, p []byte) []byte) *AccumulativeBuf

WriteApplyFn applies fn to p and write result to the buffer.

func (*AccumulativeBuf) WriteApplyFnStr added in v1.0.2

func (b *AccumulativeBuf) WriteApplyFnStr(s string, fn func(dst, p []byte) []byte) *AccumulativeBuf

WriteApplyFnStr applies fn to s and write result to the buffer.

func (*AccumulativeBuf) WriteBool

func (b *AccumulativeBuf) WriteBool(v bool) *AccumulativeBuf

WriteBool writes boolean value to the buffer.

func (*AccumulativeBuf) WriteByte

func (b *AccumulativeBuf) WriteByte(p byte) *AccumulativeBuf

WriteByte writes single byte.

func (*AccumulativeBuf) WriteFloat

func (b *AccumulativeBuf) WriteFloat(f float64) *AccumulativeBuf

WriteFloat writes float value to the buffer.

func (*AccumulativeBuf) WriteInt

func (b *AccumulativeBuf) WriteInt(i int64) *AccumulativeBuf

WriteInt writes integer value to the buffer.

func (*AccumulativeBuf) WriteMarshallerTo

func (b *AccumulativeBuf) WriteMarshallerTo(m MarshallerTo) *AccumulativeBuf

WriteMarshallerTo marshal data of struct implemented MarshallerTo interface and write it to the buffer.

func (*AccumulativeBuf) WriteStr

func (b *AccumulativeBuf) WriteStr(s string) *AccumulativeBuf

WriteStr writes string to the buffer.

func (*AccumulativeBuf) WriteUint

func (b *AccumulativeBuf) WriteUint(u uint64) *AccumulativeBuf

WriteUint writes unsigned integer value to the buffer.

func (*AccumulativeBuf) WriteX

func (b *AccumulativeBuf) WriteX(x interface{}) *AccumulativeBuf

WriteX write v with arbitrary type to the buffer.

type ChainBuf

type ChainBuf []byte

ChainBuf is a primitive byte buffer with chain call support.

func (*ChainBuf) Bytes

func (b *ChainBuf) Bytes() []byte

Bytes returns contents of the buffer.

func (*ChainBuf) BytesCopy

func (b *ChainBuf) BytesCopy() []byte

BytesCopy returns copy of the buffer.

func (*ChainBuf) Cap

func (b *ChainBuf) Cap() int

func (*ChainBuf) Grow

func (b *ChainBuf) Grow(newLen int) *ChainBuf

Grow increases length of the buffer.

func (*ChainBuf) GrowDelta

func (b *ChainBuf) GrowDelta(delta int) *ChainBuf

GrowDelta increases length of the buffer to actual length + delta.

See Grow().

func (*ChainBuf) Len

func (b *ChainBuf) Len() int

func (*ChainBuf) Replace

func (b *ChainBuf) Replace(old, new []byte, n int) *ChainBuf

Replace replaces old bytes to new in buffer.

func (*ChainBuf) ReplaceAll

func (b *ChainBuf) ReplaceAll(old, new []byte) *ChainBuf

ReplaceAll replace all occurrences of old bytes to new in buffer.

func (*ChainBuf) ReplaceStr

func (b *ChainBuf) ReplaceStr(old, new string, n int) *ChainBuf

ReplaceStr replace old to new substrings in buffer.

func (*ChainBuf) ReplaceStrAll

func (b *ChainBuf) ReplaceStrAll(old, new string) *ChainBuf

ReplaceStrAll replaces all occurrences of old substrings to new in buffer.

func (*ChainBuf) Reset

func (b *ChainBuf) Reset() *ChainBuf

func (*ChainBuf) String

func (b *ChainBuf) String() string

Get contents of the buffer as string.

func (*ChainBuf) StringCopy

func (b *ChainBuf) StringCopy() string

StringCopy returns copy of the buffer contents as string.

func (*ChainBuf) Write

func (b *ChainBuf) Write(p []byte) *ChainBuf

Write bytes to the buffer.

func (*ChainBuf) WriteApplyFn added in v1.0.2

func (b *ChainBuf) WriteApplyFn(p []byte, fn func(dst, p []byte) []byte) *ChainBuf

WriteApplyFn applies fn to p and write result to the buffer.

func (*ChainBuf) WriteApplyFnStr added in v1.0.2

func (b *ChainBuf) WriteApplyFnStr(s string, fn func(dst, p []byte) []byte) *ChainBuf

WriteApplyFnStr applies fn to s and write result to the buffer.

func (*ChainBuf) WriteBool

func (b *ChainBuf) WriteBool(v bool) *ChainBuf

WriteBool writes boolean value to the buffer.

func (*ChainBuf) WriteByte

func (b *ChainBuf) WriteByte(p byte) *ChainBuf

WriteByte writes single byte.

func (*ChainBuf) WriteFloat

func (b *ChainBuf) WriteFloat(f float64) *ChainBuf

WriteFloat writes float value to the buffer.

func (*ChainBuf) WriteInt

func (b *ChainBuf) WriteInt(i int64) *ChainBuf

WriteInt writes integer value to the buffer.

func (*ChainBuf) WriteMarshallerTo

func (b *ChainBuf) WriteMarshallerTo(m MarshallerTo) *ChainBuf

WriteMarshallerTo marshal data of struct implemented MarshallerTo interface and write it to the buffer.

func (*ChainBuf) WriteStr

func (b *ChainBuf) WriteStr(s string) *ChainBuf

WriteStr writes string to the buffer.

func (*ChainBuf) WriteUint

func (b *ChainBuf) WriteUint(u uint64) *ChainBuf

WriteUint writes unsigned integer value to the buffer.

func (*ChainBuf) WriteX

func (b *ChainBuf) WriteX(x interface{}) *ChainBuf

WriteX write x with arbitrary type to the buffer.

type MarshallerTo

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

MarshallerTo interface to write struct like Protobuf.

Jump to

Keyboard shortcuts

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