buffer

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer interface {
	// Len 获取字节长度
	Len() int
	// Bytes 获取所有字节(性能较低,不推荐使用)
	Bytes() []byte
	// Mount 挂载数据到Buffer上
	Mount(block interface{}, whence ...Whence)
	// Malloc 分配一块内存给Writer
	Malloc(cap int, whence ...Whence) *Writer
	// Range 迭代
	Range(fn func(node *NocopyNode) bool)
	// Release 释放
	Release()
}

type NocopyBuffer

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

func NewNocopyBuffer

func NewNocopyBuffer(blocks ...interface{}) *NocopyBuffer

func (*NocopyBuffer) Bytes

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

Bytes 获取字节

func (*NocopyBuffer) Len

func (b *NocopyBuffer) Len() int

Len 获取字节长度

func (*NocopyBuffer) Malloc

func (b *NocopyBuffer) Malloc(cap int, whence ...Whence) *Writer

Malloc 分配一块内存给Writer

func (*NocopyBuffer) Mount

func (b *NocopyBuffer) Mount(block interface{}, whence ...Whence)

Mount 挂载块到Buffer上

func (*NocopyBuffer) Nodes

func (b *NocopyBuffer) Nodes() int

Nodes 获取节点数

func (*NocopyBuffer) Range

func (b *NocopyBuffer) Range(fn func(node *NocopyNode) bool)

Range 迭代

func (*NocopyBuffer) Release

func (b *NocopyBuffer) Release()

Release 释放

type NocopyNode

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

func (*NocopyNode) Bytes

func (n *NocopyNode) Bytes() []byte

Bytes 获取该节点的字节数据

func (*NocopyNode) Len

func (n *NocopyNode) Len() int

Len 获取字节长度

func (*NocopyNode) Next

func (n *NocopyNode) Next() *NocopyNode

Next 下一个节点

func (*NocopyNode) Release

func (n *NocopyNode) Release()

Release 释放

type Reader

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

func NewReader

func NewReader(data []byte) *Reader

func (*Reader) ReadBool

func (r *Reader) ReadBool() (bool, error)

ReadBool 读取bool值

func (*Reader) ReadBools

func (r *Reader) ReadBools(n int) ([]bool, error)

ReadBools 读取多个bool值

func (*Reader) ReadByte

func (r *Reader) ReadByte() (byte, error)

ReadByte 读取byte值

func (*Reader) ReadBytes

func (r *Reader) ReadBytes(n int) ([]byte, error)

ReadBytes 读取多个byte值

func (*Reader) ReadFloat32

func (r *Reader) ReadFloat32(order binary.ByteOrder) (float32, error)

ReadFloat32 读取float32值

func (*Reader) ReadFloat32s

func (r *Reader) ReadFloat32s(order binary.ByteOrder, n int) ([]float32, error)

ReadFloat32s 读取多个float32值

func (*Reader) ReadFloat64

func (r *Reader) ReadFloat64(order binary.ByteOrder) (float64, error)

ReadFloat64 读取float64值

func (*Reader) ReadFloat64s

func (r *Reader) ReadFloat64s(order binary.ByteOrder, n int) ([]float64, error)

ReadFloat64s 读取多个float64值

func (*Reader) ReadInt16

func (r *Reader) ReadInt16(order binary.ByteOrder) (int16, error)

ReadInt16 读取int16值

func (*Reader) ReadInt16s

func (r *Reader) ReadInt16s(order binary.ByteOrder, n int) ([]int16, error)

ReadInt16s 读取多个int16值

func (*Reader) ReadInt32

func (r *Reader) ReadInt32(order binary.ByteOrder) (int32, error)

ReadInt32 读取int32值

func (*Reader) ReadInt32s

func (r *Reader) ReadInt32s(order binary.ByteOrder, n int) ([]int32, error)

ReadInt32s 读取多个int32值

func (*Reader) ReadInt64

func (r *Reader) ReadInt64(order binary.ByteOrder) (int64, error)

ReadInt64 读取int64值

func (*Reader) ReadInt64s

func (r *Reader) ReadInt64s(order binary.ByteOrder, n int) ([]int64, error)

ReadInt64s 读取多个int64值

func (*Reader) ReadInt8

func (r *Reader) ReadInt8() (int8, error)

ReadInt8 读取int8值

func (*Reader) ReadInt8s

func (r *Reader) ReadInt8s(n int) ([]int8, error)

ReadInt8s 读取多个int8值

func (*Reader) ReadRune

func (r *Reader) ReadRune(order binary.ByteOrder) (rune, error)

ReadRune 读取rune值

func (*Reader) ReadRunes

func (r *Reader) ReadRunes(order binary.ByteOrder, n int) ([]rune, error)

ReadRunes 读取多个rune值

func (*Reader) ReadString

func (r *Reader) ReadString(len int) (string, error)

ReadString 读取string值

func (*Reader) ReadUint16

func (r *Reader) ReadUint16(order binary.ByteOrder) (uint16, error)

ReadUint16 读取uint16值

func (*Reader) ReadUint16s

func (r *Reader) ReadUint16s(order binary.ByteOrder, n int) ([]uint16, error)

ReadUint16s 读取多个uint16值

func (*Reader) ReadUint32

func (r *Reader) ReadUint32(order binary.ByteOrder) (uint32, error)

ReadUint32 读取uint32值

func (*Reader) ReadUint32s

func (r *Reader) ReadUint32s(order binary.ByteOrder, n int) ([]uint32, error)

ReadUint32s 读取多个uint32值

func (*Reader) ReadUint64

func (r *Reader) ReadUint64(order binary.ByteOrder) (uint64, error)

ReadUint64 读取uint64值

func (*Reader) ReadUint64s

func (r *Reader) ReadUint64s(order binary.ByteOrder, n int) ([]uint64, error)

ReadUint64s 读取多个uint64值

func (*Reader) ReadUint8

func (r *Reader) ReadUint8() (uint8, error)

ReadUint8 读取uint8值

func (*Reader) ReadUint8s

func (r *Reader) ReadUint8s(n int) ([]uint8, error)

ReadUint8s 读取多个uint8值

func (*Reader) Reset

func (r *Reader) Reset()

Reset 重置

func (*Reader) Seek

func (r *Reader) Seek(offset int64, whence int) (int64, error)

Seek implements the io.Seeker interface.

type Whence

type Whence int
const (
	Head Whence = iota // 头部
	Tail               // 尾部
)

type Writer

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

func NewWriter

func NewWriter(cap ...int) *Writer

func (*Writer) Available

func (w *Writer) Available() int

Available 返回可用空间

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

Bytes 获取字节数据

func (*Writer) Cap

func (w *Writer) Cap() int

Cap 返回容量

func (*Writer) Grow

func (w *Writer) Grow(n int)

Grow 增长空间

func (*Writer) Len

func (w *Writer) Len() int

Len 返回数据长度

func (*Writer) Reset

func (w *Writer) Reset()

Reset 复位

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

写数据,实现io.Writer

func (*Writer) WriteBools

func (w *Writer) WriteBools(values ...bool)

WriteBools 写入bool值

func (*Writer) WriteBytes

func (w *Writer) WriteBytes(values ...byte)

WriteBytes 写入字节序

func (*Writer) WriteFloat32s

func (w *Writer) WriteFloat32s(order binary.ByteOrder, values ...float32)

WriteFloat32s 写入float32

func (*Writer) WriteFloat64s

func (w *Writer) WriteFloat64s(order binary.ByteOrder, values ...float64)

WriteFloat64s 写入float64

func (*Writer) WriteInt16s

func (w *Writer) WriteInt16s(order binary.ByteOrder, values ...int16)

WriteInt16s 写入int16

func (*Writer) WriteInt32s

func (w *Writer) WriteInt32s(order binary.ByteOrder, values ...int32)

WriteInt32s 写入int32

func (*Writer) WriteInt64s

func (w *Writer) WriteInt64s(order binary.ByteOrder, values ...int64)

WriteInt64s 写入int64

func (*Writer) WriteInt8s

func (w *Writer) WriteInt8s(values ...int8)

WriteInt8s 写入int8

func (*Writer) WriteRunes

func (w *Writer) WriteRunes(order binary.ByteOrder, values ...rune)

WriteRunes 写入rune

func (*Writer) WriteString

func (w *Writer) WriteString(str string)

WriteString 写入字符串

func (*Writer) WriteUint16s

func (w *Writer) WriteUint16s(order binary.ByteOrder, values ...uint16)

WriteUint16s 写入uint16

func (*Writer) WriteUint32s

func (w *Writer) WriteUint32s(order binary.ByteOrder, values ...uint32)

WriteUint32s 写入uint32

func (*Writer) WriteUint64s

func (w *Writer) WriteUint64s(order binary.ByteOrder, values ...uint64)

WriteUint64s 写入uint64

func (*Writer) WriteUint8s

func (w *Writer) WriteUint8s(values ...uint8)

WriteUint8s 写入uint8

type WriterPool

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

func NewWriterPool

func NewWriterPool(capacities []int) *WriterPool

func (*WriterPool) Get

func (p *WriterPool) Get(cap int) *Writer

Get 获取

func (*WriterPool) Put

func (p *WriterPool) Put(w *Writer)

Put 放回

Jump to

Keyboard shortcuts

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