buffer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMaxSize = errors.New("code: 3005 - buffer maximum size")
	Empty      = new(Buffer)
)

Functions

This section is empty.

Types

type Buffer

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

func Containing added in v0.0.6

func Containing(data []byte, max int) *Buffer

create a buffer that contains the specified data (mostly useful for tests)

func New

func New(min uint32, max uint32) *Buffer

func (Buffer) Bytes

func (b Buffer) Bytes() ([]byte, error)

func (*Buffer) Close added in v0.0.6

func (b *Buffer) Close() error

io.Closer

func (*Buffer) EnsureCapacity added in v0.0.9

func (b *Buffer) EnsureCapacity(l int) bool

func (*Buffer) Error

func (b *Buffer) Error() error

func (*Buffer) Len

func (b *Buffer) Len() int

func (*Buffer) Max

func (b *Buffer) Max() int

func (*Buffer) MustString

func (b *Buffer) MustString() string

func (Buffer) OKBytes added in v0.0.9

func (b Buffer) OKBytes() []byte

func (*Buffer) Pad added in v0.0.7

func (b *Buffer) Pad(padSize int) error

ensure that we have enough space for padSize

func (*Buffer) Read added in v0.0.6

func (b *Buffer) Read(p []byte) (int, error)

io.Reader

func (*Buffer) Release

func (b *Buffer) Release()

func (*Buffer) Reset

func (b *Buffer) Reset()

func (*Buffer) Seek added in v0.0.9

func (b *Buffer) Seek(offset int64, whence int) (int64, error)

func (Buffer) SqliteBytes

func (b Buffer) SqliteBytes() ([]byte, error)

optimization for passing the result to the ExecTerminated method of sqlite.Conn.

func (*Buffer) String

func (b *Buffer) String() (string, error)

func (Buffer) TakeBytes added in v0.0.6

func (b Buffer) TakeBytes(l int) ([]byte, error)

An advanced function. Some code might want to manipulate a []byte directly while leveraging the pre-allocated nature of a pooled buffer. Importantly, the returned bytes are not cleared

func (*Buffer) Truncate

func (b *Buffer) Truncate(n int)

func (*Buffer) UnsafeString added in v0.0.6

func (b *Buffer) UnsafeString() (string, error)

func (*Buffer) Write

func (b *Buffer) Write(data []byte) (int, error)

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(byte byte)

func (*Buffer) WriteByteUnsafe

func (b *Buffer) WriteByteUnsafe(byte byte)

Our caller knows that there's enough space in data (probably because it used WritePad)

func (*Buffer) WritePad

func (b *Buffer) WritePad(data []byte, padSize int) (int, error)

Write and ensure enough capacity for len(data) + padSize Meant to be used with WriteByteUnsafe.

func (*Buffer) WriteString

func (b *Buffer) WriteString(data string)

type Config

type Config struct {
	Count uint16 `json:"count"`
	Min   uint32 `json:"min"`
	Max   uint32 `json:"max"`
}

type Pool

type Pool struct {
	*concurrent.Pool[*Buffer]
	// contains filtered or unexported fields
}

func NewPool

func NewPool(count uint16, minSize uint32, maxSize uint32) Pool

func NewPoolFromConfig

func NewPoolFromConfig(config Config) Pool

func (Pool) Checkout

func (p Pool) Checkout() *Buffer

func (*Pool) CheckoutMax added in v0.0.6

func (p *Pool) CheckoutMax(maxSize uint32) *Buffer

Jump to

Keyboard shortcuts

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