buf

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: GPL-2.0 Imports: 11 Imported by: 386

Documentation

Index

Constants

View Source
const (
	BufferSize    = 32 * 1024
	UDPBufferSize = 16 * 1024
)

Variables

View Source
var DefaultAllocator = newDefaultAllocator()

Functions

func CopyMulti added in v0.1.8

func CopyMulti(toBuffer []byte, buffers []*Buffer) int

func Get

func Get(size int) []byte

func LenMulti

func LenMulti(buffers []*Buffer) int

func Make deprecated

func Make(size int) []byte

Deprecated: use array instead.

func Put

func Put(buf []byte) error

func ReleaseMulti

func ReleaseMulti(buffers []*Buffer)

func ToSliceMulti

func ToSliceMulti(buffers []*Buffer) [][]byte

Types

type Allocator

type Allocator interface {
	Get(size int) []byte
	Put(buf []byte) error
}

type Buffer

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

func As

func As(data []byte) *Buffer

func New

func New() *Buffer

func NewPacket

func NewPacket() *Buffer

func NewSize

func NewSize(size int) *Buffer

func With

func With(data []byte) *Buffer

func (*Buffer) Advance

func (b *Buffer) Advance(from int)

func (*Buffer) Byte

func (b *Buffer) Byte(index int) byte

func (*Buffer) Bytes

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

func (*Buffer) Cap

func (b *Buffer) Cap() int

func (*Buffer) DecRef

func (b *Buffer) DecRef()

func (*Buffer) Extend

func (b *Buffer) Extend(n int) []byte

func (*Buffer) ExtendHeader

func (b *Buffer) ExtendHeader(n int) []byte

func (*Buffer) FreeBytes

func (b *Buffer) FreeBytes() []byte

func (*Buffer) FreeLen

func (b *Buffer) FreeLen() int

func (*Buffer) From

func (b *Buffer) From(n int) []byte

func (*Buffer) FullReset deprecated

func (b *Buffer) FullReset()

Deprecated: use Reset instead.

func (*Buffer) IncRef

func (b *Buffer) IncRef()

func (*Buffer) Index

func (b *Buffer) Index(start int) []byte

func (*Buffer) IsEmpty

func (b *Buffer) IsEmpty() bool

func (*Buffer) IsFull

func (b *Buffer) IsFull() bool

func (*Buffer) Leak added in v0.3.0

func (b *Buffer) Leak()

func (*Buffer) Len

func (b *Buffer) Len() int

func (*Buffer) OverCap added in v0.3.0

func (b *Buffer) OverCap(n int)

func (*Buffer) Range

func (b *Buffer) Range(start, end int) []byte

func (*Buffer) RawCap added in v0.3.0

func (b *Buffer) RawCap() int

func (*Buffer) Read

func (b *Buffer) Read(data []byte) (n int, err error)

func (*Buffer) ReadAtLeastFrom

func (b *Buffer) ReadAtLeastFrom(r io.Reader, min int) (int64, error)

func (*Buffer) ReadByte

func (b *Buffer) ReadByte() (byte, error)

func (*Buffer) ReadBytes

func (b *Buffer) ReadBytes(n int) ([]byte, error)

func (*Buffer) ReadFrom

func (b *Buffer) ReadFrom(reader io.Reader) (n int64, err error)

func (*Buffer) ReadFullFrom

func (b *Buffer) ReadFullFrom(r io.Reader, size int) (n int, err error)

func (*Buffer) ReadOnceFrom

func (b *Buffer) ReadOnceFrom(r io.Reader) (int, error)

func (*Buffer) ReadPacketFrom

func (b *Buffer) ReadPacketFrom(r net.PacketConn) (int64, net.Addr, error)

func (*Buffer) Release

func (b *Buffer) Release()

func (*Buffer) Reserve added in v0.3.0

func (b *Buffer) Reserve(n int)

func (*Buffer) Reset

func (b *Buffer) Reset()

func (*Buffer) Resize

func (b *Buffer) Resize(start, end int)

func (*Buffer) SetByte

func (b *Buffer) SetByte(index int, value byte)

func (*Buffer) Start

func (b *Buffer) Start() int

func (*Buffer) To

func (b *Buffer) To(n int) []byte

func (*Buffer) ToOwned

func (b *Buffer) ToOwned() *Buffer

func (*Buffer) Truncate

func (b *Buffer) Truncate(to int)

func (*Buffer) Write

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

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(d byte) error

func (*Buffer) WriteRandom

func (b *Buffer) WriteRandom(size int) []byte

func (*Buffer) WriteRune

func (b *Buffer) WriteRune(s rune) (int, error)

func (*Buffer) WriteString

func (b *Buffer) WriteString(s string) (n int, err error)

func (*Buffer) WriteTo

func (b *Buffer) WriteTo(w io.Writer) (int64, error)

func (*Buffer) WriteZero

func (b *Buffer) WriteZero() error

func (*Buffer) WriteZeroN

func (b *Buffer) WriteZeroN(n int) error

Jump to

Keyboard shortcuts

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