bytes_buffer

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: GPL-3.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer interface {
	Reader
	Writer
}

func NewBaseBuffer

func NewBaseBuffer(cap uint32, autoGrow bool) Buffer

type Pool

type Pool struct {
	sync.Pool
}

func NewBaseBufferPool

func NewBaseBufferPool(cap uint32, autoGrow bool) *Pool

func NewRingBufferPool added in v1.5.6

func NewRingBufferPool(cap uint32, autoGrow bool) *Pool

func (*Pool) Get

func (p *Pool) Get() Buffer

func (*Pool) Put

func (p *Pool) Put(b Buffer)

type RReader added in v1.5.6

type RReader interface {
	IsCanGrow() bool
	GetCapacity() int  // 获取总空间大小
	GetDataSize() int  // 获取占用的数据空间大小
	GetTailSize() int  // 获取尾部空间大小
	GetEmptySize() int // 获取空余总空间大小
	IsEmpty() bool

	io.Reader
	Peek() (first, end []byte) //查看,但不取出数据
	PeekLen(outLen int) (first, end []byte)
	PeekOut() (first, end []byte) //取出数据,但不做数据拷贝,有数据被覆盖风险
	PeekOutLen(outLen int) (first, end []byte, err error)
	CopyOut(out []byte) int                  // 读取最大out长度的数据,返回读出数据长度
	CopyOutLen(out []byte, outLen int) error // 读取outLen长度的数据,如果数据不足 outLen 返回 error
}

type Reader added in v1.1.5

type Reader interface {
	IsCanGrow() bool
	GetCapacity() int  // 获取总空间大小
	GetDataSize() int  // 获取占用的数据空间大小
	GetTailSize() int  // 获取尾部空间大小
	GetEmptySize() int // 获取空余总空间大小
	IsEmpty() bool

	io.Reader
	Peek() []byte //查看,但不取出数据
	PeekLen(outLen int) []byte
	PeekOut() []byte //取出数据,但不做数据拷贝,有数据被覆盖风险
	PeekOutLen(outLen int) ([]byte, error)
	CopyOut(out []byte) int                  // 读取最大out长度的数据,返回读出数据长度
	CopyOutLen(out []byte, outLen int) error // 读取outLen长度的数据,如果数据不足 outLen 返回 error
}

func Warp added in v1.0.11

func Warp(b []byte) Reader

type RingBuffer added in v1.5.6

type RingBuffer interface {
	RReader
	Writer
}

func NewRingBuffer added in v1.5.6

func NewRingBuffer(cap uint32, autoGrow bool) RingBuffer

type Writer added in v1.1.5

type Writer interface {
	io.Writer
	Clean()
	Reserve(cap int) error
	ResetLen(len int)
	AssignString(s string) error
	AssignBytes(p []byte) error
	AppendString(s string) error
	AppendBytes(p []byte) error // 将p写入 ringBuffer,如果 ringBuffer 不足,返回错误

	GetTailEmptyBytes() []byte //与AddLen配合使用,用于需要转写数据的场景但又只有[]byte接口的地方,但需要注意,有可能尾部空间都有数据时,可能需要自行调用MoveHeadZeroRIndex释放空间
	AddLen(len int)            //与GetEmptyBytes配合使用
	MoveHeadZeroRIndex()
}

Jump to

Keyboard shortcuts

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