buf

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: Apache-2.0 Imports: 4 Imported by: 13

README

GoTH-bytebuf

make byte stream operation more easily

HOWTO

create empty byte buffer

    buf := EmptyByteBuf()

write string to byte buffer

    buf.WriteString("abcdef")

write int64 value to byte buffer

    buf.WriteInt64(int64(12345))

make a clone of current readable bytes

    clone := buf.Clone()

read 8 bytes array as int64 value from byte buffer

    buf := EmptyByteBuf()
    buf.WriteInt64(int64(12345)) // readable bytes len = 8
    v := buf.ReadInt64() // v = int64(12345)

skip 2 bytes and read 3 bytes of byte buffer

    bs := buf.Skip(2).ReadBytes(3)

reset byte buffer

    buf.Reset()

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInsufficientSize = fmt.Errorf("insufficient size")
View Source
var ErrNilObject = fmt.Errorf("nil object")

Functions

This section is empty.

Types

type ByteBuf

type ByteBuf interface {
	io.Writer
	io.Reader
	io.Closer
	io.WriterAt
	ReaderIndex() int
	WriterIndex() int
	MarkReaderIndex() ByteBuf
	ResetReaderIndex() ByteBuf
	MarkWriterIndex() ByteBuf
	ResetWriterIndex() ByteBuf
	Reset() ByteBuf
	Bytes() []byte
	ReadableBytes() int
	Cap() int
	Grow(v int) ByteBuf
	Skip(v int) ByteBuf
	Clone() ByteBuf
	WriteByte(c byte) ByteBuf
	WriteBytes(bs []byte) ByteBuf
	WriteString(s string) ByteBuf
	WriteByteBuf(buf ByteBuf) ByteBuf
	WriteReader(reader io.Reader) ByteBuf
	WriteInt16(v int16) ByteBuf
	WriteInt32(v int32) ByteBuf
	WriteInt64(v int64) ByteBuf
	WriteUInt16(v uint16) ByteBuf
	WriteUInt32(v uint32) ByteBuf
	WriteUInt64(v uint64) ByteBuf
	WriteFloat32(v float32) ByteBuf
	WriteFloat64(v float64) ByteBuf
	WriteInt16LE(v int16) ByteBuf
	WriteInt32LE(v int32) ByteBuf
	WriteInt64LE(v int64) ByteBuf
	WriteUInt16LE(v uint16) ByteBuf
	WriteUInt32LE(v uint32) ByteBuf
	WriteUInt64LE(v uint64) ByteBuf
	WriteFloat32LE(v float32) ByteBuf
	WriteFloat64LE(v float64) ByteBuf
	ReadByte() byte
	ReadBytes(len int) []byte
	ReadByteBuf(len int) ByteBuf
	ReadWriter(writer io.Writer) ByteBuf
	ReadInt16() int16
	ReadInt32() int32
	ReadInt64() int64
	ReadUInt16() uint16
	ReadUInt32() uint32
	ReadUInt64() uint64
	ReadFloat32() float32
	ReadFloat64() float64
	ReadInt16LE() int16
	ReadInt32LE() int32
	ReadInt64LE() int64
	ReadUInt16LE() uint16
	ReadUInt32LE() uint32
	ReadUInt64LE() uint64
	ReadFloat32LE() float32
	ReadFloat64LE() float64
}

func EmptyByteBuf

func EmptyByteBuf() ByteBuf

func NewByteBuf

func NewByteBuf(bs []byte) ByteBuf

func NewByteBufString

func NewByteBufString(str string) ByteBuf

type DefaultByteBuf

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

func (*DefaultByteBuf) Bytes

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

func (*DefaultByteBuf) Cap

func (b *DefaultByteBuf) Cap() int

func (*DefaultByteBuf) Clone

func (b *DefaultByteBuf) Clone() ByteBuf

func (*DefaultByteBuf) Close

func (b *DefaultByteBuf) Close() error

func (*DefaultByteBuf) Grow

func (b *DefaultByteBuf) Grow(v int) ByteBuf

func (*DefaultByteBuf) MarkReaderIndex

func (b *DefaultByteBuf) MarkReaderIndex() ByteBuf

func (*DefaultByteBuf) MarkWriterIndex

func (b *DefaultByteBuf) MarkWriterIndex() ByteBuf

func (*DefaultByteBuf) Read

func (b *DefaultByteBuf) Read(p []byte) (n int, err error)

func (*DefaultByteBuf) ReadByte

func (b *DefaultByteBuf) ReadByte() byte

func (*DefaultByteBuf) ReadByteBuf

func (b *DefaultByteBuf) ReadByteBuf(len int) ByteBuf

func (*DefaultByteBuf) ReadBytes

func (b *DefaultByteBuf) ReadBytes(len int) []byte

func (*DefaultByteBuf) ReadFloat32

func (b *DefaultByteBuf) ReadFloat32() float32

func (*DefaultByteBuf) ReadFloat32LE

func (b *DefaultByteBuf) ReadFloat32LE() float32

func (*DefaultByteBuf) ReadFloat64

func (b *DefaultByteBuf) ReadFloat64() float64

func (*DefaultByteBuf) ReadFloat64LE

func (b *DefaultByteBuf) ReadFloat64LE() float64

func (*DefaultByteBuf) ReadInt16

func (b *DefaultByteBuf) ReadInt16() int16

func (*DefaultByteBuf) ReadInt16LE

func (b *DefaultByteBuf) ReadInt16LE() int16

func (*DefaultByteBuf) ReadInt32

func (b *DefaultByteBuf) ReadInt32() int32

func (*DefaultByteBuf) ReadInt32LE

func (b *DefaultByteBuf) ReadInt32LE() int32

func (*DefaultByteBuf) ReadInt64

func (b *DefaultByteBuf) ReadInt64() int64

func (*DefaultByteBuf) ReadInt64LE

func (b *DefaultByteBuf) ReadInt64LE() int64

func (*DefaultByteBuf) ReadUInt16

func (b *DefaultByteBuf) ReadUInt16() uint16

func (*DefaultByteBuf) ReadUInt16LE

func (b *DefaultByteBuf) ReadUInt16LE() uint16

func (*DefaultByteBuf) ReadUInt32

func (b *DefaultByteBuf) ReadUInt32() uint32

func (*DefaultByteBuf) ReadUInt32LE

func (b *DefaultByteBuf) ReadUInt32LE() uint32

func (*DefaultByteBuf) ReadUInt64

func (b *DefaultByteBuf) ReadUInt64() uint64

func (*DefaultByteBuf) ReadUInt64LE

func (b *DefaultByteBuf) ReadUInt64LE() uint64

func (*DefaultByteBuf) ReadWriter

func (b *DefaultByteBuf) ReadWriter(writer io.Writer) ByteBuf

func (*DefaultByteBuf) ReadableBytes

func (b *DefaultByteBuf) ReadableBytes() int

func (*DefaultByteBuf) ReaderIndex

func (b *DefaultByteBuf) ReaderIndex() int

func (*DefaultByteBuf) Reset

func (b *DefaultByteBuf) Reset() ByteBuf

func (*DefaultByteBuf) ResetReaderIndex

func (b *DefaultByteBuf) ResetReaderIndex() ByteBuf

func (*DefaultByteBuf) ResetWriterIndex

func (b *DefaultByteBuf) ResetWriterIndex() ByteBuf

func (*DefaultByteBuf) Skip

func (b *DefaultByteBuf) Skip(v int) ByteBuf

func (*DefaultByteBuf) Write

func (b *DefaultByteBuf) Write(p []byte) (n int, err error)

func (*DefaultByteBuf) WriteAt added in v1.0.1

func (b *DefaultByteBuf) WriteAt(p []byte, offset int64) (n int, err error)

func (*DefaultByteBuf) WriteByte

func (b *DefaultByteBuf) WriteByte(c byte) ByteBuf

func (*DefaultByteBuf) WriteByteBuf

func (b *DefaultByteBuf) WriteByteBuf(buf ByteBuf) ByteBuf

func (*DefaultByteBuf) WriteBytes

func (b *DefaultByteBuf) WriteBytes(bs []byte) ByteBuf

func (*DefaultByteBuf) WriteFloat32

func (b *DefaultByteBuf) WriteFloat32(v float32) ByteBuf

func (*DefaultByteBuf) WriteFloat32LE

func (b *DefaultByteBuf) WriteFloat32LE(v float32) ByteBuf

func (*DefaultByteBuf) WriteFloat64

func (b *DefaultByteBuf) WriteFloat64(v float64) ByteBuf

func (*DefaultByteBuf) WriteFloat64LE

func (b *DefaultByteBuf) WriteFloat64LE(v float64) ByteBuf

func (*DefaultByteBuf) WriteInt16

func (b *DefaultByteBuf) WriteInt16(v int16) ByteBuf

func (*DefaultByteBuf) WriteInt16LE

func (b *DefaultByteBuf) WriteInt16LE(v int16) ByteBuf

func (*DefaultByteBuf) WriteInt32

func (b *DefaultByteBuf) WriteInt32(v int32) ByteBuf

func (*DefaultByteBuf) WriteInt32LE

func (b *DefaultByteBuf) WriteInt32LE(v int32) ByteBuf

func (*DefaultByteBuf) WriteInt64

func (b *DefaultByteBuf) WriteInt64(v int64) ByteBuf

func (*DefaultByteBuf) WriteInt64LE

func (b *DefaultByteBuf) WriteInt64LE(v int64) ByteBuf

func (*DefaultByteBuf) WriteReader

func (b *DefaultByteBuf) WriteReader(reader io.Reader) ByteBuf

func (*DefaultByteBuf) WriteString

func (b *DefaultByteBuf) WriteString(s string) ByteBuf

func (*DefaultByteBuf) WriteUInt16

func (b *DefaultByteBuf) WriteUInt16(v uint16) ByteBuf

func (*DefaultByteBuf) WriteUInt16LE

func (b *DefaultByteBuf) WriteUInt16LE(v uint16) ByteBuf

func (*DefaultByteBuf) WriteUInt32

func (b *DefaultByteBuf) WriteUInt32(v uint32) ByteBuf

func (*DefaultByteBuf) WriteUInt32LE

func (b *DefaultByteBuf) WriteUInt32LE(v uint32) ByteBuf

func (*DefaultByteBuf) WriteUInt64

func (b *DefaultByteBuf) WriteUInt64(v uint64) ByteBuf

func (*DefaultByteBuf) WriteUInt64LE

func (b *DefaultByteBuf) WriteUInt64LE(v uint64) ByteBuf

func (*DefaultByteBuf) WriterIndex

func (b *DefaultByteBuf) WriterIndex() int

Jump to

Keyboard shortcuts

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