bytebuf

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 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)

Conversion to bytes function.

func ChainBufToBytes

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

Conversion to bytes function.

Types

type AccumulativeBuf

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

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

Get contents of the buffer.

func (*AccumulativeBuf) BytesCopy

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

Get copy of the buffer.

func (*AccumulativeBuf) Cap

func (b *AccumulativeBuf) Cap() int

Get capacity of the buffer.

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 length of the buffer.

func (*AccumulativeBuf) GrowDelta

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

Grow length of the buffer to actual length + delta.

See Grow().

func (*AccumulativeBuf) Len

func (b *AccumulativeBuf) Len() int

Get length of the buffer.

func (*AccumulativeBuf) RangeBytes

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

Get buffer bytes from offset off with length len.

func (*AccumulativeBuf) RangeBytesCopy

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

Copy version of RangeBytes().

func (*AccumulativeBuf) RangeString

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

Get buffer bytes as string from offset off with length len.

func (*AccumulativeBuf) RangeStringCopy

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

Copy version of RangeString().

func (*AccumulativeBuf) Replace

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

Replace old to new bytes in buffer.

func (*AccumulativeBuf) ReplaceAll

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

Replace all old to new bytes in buffer.

func (*AccumulativeBuf) ReplaceStr

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

Replace old to new strings in buffer.

func (*AccumulativeBuf) ReplaceStrAll

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

Replace all old to new strings in buffer.

func (*AccumulativeBuf) Reset

func (b *AccumulativeBuf) Reset() *AccumulativeBuf

Reset length of the buffer.

func (*AccumulativeBuf) StakeOut

func (b *AccumulativeBuf) StakeOut() *AccumulativeBuf

Stake out current offset for further use.

func (*AccumulativeBuf) StakedBytes

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

Get accumulated bytes from staked offset.

func (*AccumulativeBuf) StakedBytesCopy

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

Get copy of accumulated bytes from staked offset.

func (*AccumulativeBuf) StakedLen

func (b *AccumulativeBuf) StakedLen() int

Get length of accumulated bytes.

func (*AccumulativeBuf) StakedOffset

func (b *AccumulativeBuf) StakedOffset() int

Get staked offset.

func (*AccumulativeBuf) StakedString

func (b *AccumulativeBuf) StakedString() string

Get accumulated bytes as string.

func (*AccumulativeBuf) StakedStringCopy

func (b *AccumulativeBuf) StakedStringCopy() string

Get 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

Get copy of the buffer as string.

func (*AccumulativeBuf) Write

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

Write bytes to the buffer.

func (*AccumulativeBuf) WriteBool

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

Write boolean value to the buffer.

func (*AccumulativeBuf) WriteByte

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

Write single byte.

func (*AccumulativeBuf) WriteFloat

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

Write float value to the buffer.

func (*AccumulativeBuf) WriteInt

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

Write integer value to the buffer.

func (*AccumulativeBuf) WriteMarshallerTo

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

Marshal data of struct implemented MarshallerTo interface.

func (*AccumulativeBuf) WriteStr

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

Write string to the buffer.

func (*AccumulativeBuf) WriteUint

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

Write unsigned integer value to the buffer.

func (*AccumulativeBuf) WriteX

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

Write v with arbitrary type to the buffer.

type ChainBuf

type ChainBuf []byte

Primitive byte buffer with chain call support.

func (*ChainBuf) Bytes

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

Get contents of the buffer.

func (*ChainBuf) BytesCopy

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

Get copy of the buffer.

func (*ChainBuf) Cap

func (b *ChainBuf) Cap() int

Get capacity of the buffer.

func (*ChainBuf) Grow

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

Grow length of the buffer.

func (*ChainBuf) GrowDelta

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

Grow length of the buffer to actual length + delta.

See Grow().

func (*ChainBuf) Len

func (b *ChainBuf) Len() int

Get length of the buffer.

func (*ChainBuf) Replace

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

Replace old to new bytes in buffer.

func (*ChainBuf) ReplaceAll

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

Replace all old to new bytes in buffer.

func (*ChainBuf) ReplaceStr

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

Replace old to new strings in buffer.

func (*ChainBuf) ReplaceStrAll

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

Replace all old to new strings in buffer.

func (*ChainBuf) Reset

func (b *ChainBuf) Reset() *ChainBuf

Reset length of the buffer.

func (*ChainBuf) String

func (b *ChainBuf) String() string

Get contents of the buffer as string.

func (*ChainBuf) StringCopy

func (b *ChainBuf) StringCopy() string

Get copy of the buffer as string.

func (*ChainBuf) Write

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

Write bytes to the buffer.

func (*ChainBuf) WriteBool

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

Write boolean value to the buffer.

func (*ChainBuf) WriteByte

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

Write single byte.

func (*ChainBuf) WriteFloat

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

Write float value to the buffer.

func (*ChainBuf) WriteInt

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

Write integer value to the buffer.

func (*ChainBuf) WriteMarshallerTo

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

Marshal data of struct implemented MarshallerTo interface.

func (*ChainBuf) WriteStr

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

Write string to the buffer.

func (*ChainBuf) WriteUint

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

Write unsigned integer value to the buffer.

func (*ChainBuf) WriteX

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

Write v 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