bytes_buffer

package
v1.4.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New added in v1.0.11

func New(cap uint32, autoGrow bool) *buffer

Types

type Buffer

type Buffer interface {
	Reader //读取最大len(out)长度的数据,返回已读取长度
	Writer //同AppendBytes
}

type Pool

type Pool struct {
	sync.Pool
}

func NewPool added in v1.0.11

func NewPool(cap uint32, autoGrow bool) *Pool

func (*Pool) Get

func (p *Pool) Get() Buffer

func (*Pool) Put

func (p *Pool) Put(b Buffer)

type Reader added in v1.1.5

type Reader interface {
	GetBytes() []byte
	GetTailBytes() []byte
	IsCanGrow() bool
	GetCapacity() int
	GetBytesSize() int
	GetUsedSize() int
	GetTailSize() int
	GetEmptySize() int

	io.Reader
	Peek() []byte
	PeekLen(outLen int) []byte
	TakeOut() (out []byte)
	TakeOutLen(outLen int) (out []byte, err 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 Writer added in v1.1.5

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

Jump to

Keyboard shortcuts

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