buffer

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2022 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

Package buffer implements compile.CodeBuffer and compile.DataBuffer.

Index

Constants

This section is empty.

Variables

View Source
var ErrSizeLimit error = err{}

Functions

This section is empty.

Types

type Dynamic added in v0.32.0

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

Dynamic is a variable-capacity buffer. The default value is a valid buffer.

func MakeDynamic added in v0.32.0

func MakeDynamic(b []byte) Dynamic

MakeDynamic buffer.

This function can be used in field initializer expressions. The initialized field must not be copied.

func MakeDynamicHint added in v0.32.0

func MakeDynamicHint(b []byte, maxSizeHint int) Dynamic

MakeDynamicHint avoids making excessive allocations if the maximum buffer size can be estimated in advance. The slice must be empty.

This function can be used in field initializer expressions. The initialized field must not be copied.

func NewDynamic added in v0.32.0

func NewDynamic(b []byte) *Dynamic

NewDynamic buffer.

func NewDynamicHint added in v0.32.0

func NewDynamicHint(b []byte, maxSizeHint int) *Dynamic

NewDynamicHint avoids making excessive allocations if the maximum buffer size can be estimated in advance. The slice must be empty.

func (*Dynamic) Bytes added in v0.32.0

func (d *Dynamic) Bytes() []byte

Bytes doesn't panic.

func (*Dynamic) Extend added in v0.32.0

func (d *Dynamic) Extend(addLen int) []byte

Extend doesn't panic unless out of memory.

func (*Dynamic) Len added in v0.32.0

func (d *Dynamic) Len() int

Len doesn't panic.

func (*Dynamic) PutByte added in v0.32.0

func (d *Dynamic) PutByte(value byte)

PutBytes doesn't panic unless out of memory.

func (*Dynamic) PutUint32 added in v0.32.0

func (d *Dynamic) PutUint32(i uint32)

Extend doesn't panic unless out of memory.

func (*Dynamic) ResizeBytes added in v0.32.0

func (d *Dynamic) ResizeBytes(newLen int) []byte

ResizeBytes doesn't panic unless out of memory.

type Limited added in v0.32.0

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

Limited is a dynamic buffer with a maximum size. The default value is an empty buffer that cannot grow.

func MakeLimited added in v0.32.0

func MakeLimited(b []byte, maxSize int) Limited

MakeLimited buffer with a maximum size. The slice must be empty.

This function can be used in field initializer expressions. The initialized field must not be copied.

func NewLimited added in v0.32.0

func NewLimited(b []byte, maxSize int) *Limited

NewLimited buffer with a maximum size. The slice must be empty.

func (*Limited) Bytes added in v0.32.0

func (l *Limited) Bytes() []byte

Bytes doesn't panic.

func (*Limited) Extend added in v0.32.0

func (l *Limited) Extend(n int) []byte

Extend panics with ErrSizeLimit if n bytes cannot be appended to the buffer.

func (*Limited) Len added in v0.32.0

func (l *Limited) Len() int

Len doesn't panic.

func (*Limited) PutByte added in v0.32.0

func (l *Limited) PutByte(value byte)

PutByte panics with ErrSizeLimit if the buffer is already full.

func (*Limited) PutUint32 added in v0.32.0

func (l *Limited) PutUint32(i uint32)

Extend panics with ErrSizeLimit if 4 bytes cannot be appended to the buffer.

func (*Limited) ResizeBytes added in v0.32.0

func (l *Limited) ResizeBytes(n int) []byte

ResizeBytes panics with ErrSizeLimit if n is larger than maximum buffer size.

type Static added in v0.32.0

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

Static is a fixed-capacity buffer, for wrapping a memory-mapped region. The default value is a zero-capacity buffer.

func MakeStatic added in v0.32.0

func MakeStatic(b []byte) Static

MakeStatic buffer.

This function can be used in field initializer expressions. The initialized field must not be copied.

func NewStatic added in v0.32.0

func NewStatic(b []byte) *Static

NewStatic buffer.

func (*Static) Bytes added in v0.32.0

func (s *Static) Bytes() []byte

Bytes doesn't panic.

func (*Static) Cap added in v0.32.0

func (s *Static) Cap() int

Capacity of the static buffer.

func (*Static) Extend added in v0.32.0

func (s *Static) Extend(n int) []byte

Extend panics with ErrSizeLimit if n bytes cannot be appended to the buffer.

func (*Static) Len added in v0.32.0

func (s *Static) Len() int

Len doesn't panic.

func (*Static) PutByte added in v0.32.0

func (s *Static) PutByte(value byte)

PutByte panics with ErrSizeLimit if the buffer is already full.

func (*Static) PutUint32 added in v0.32.0

func (s *Static) PutUint32(i uint32)

Extend panics with ErrSizeLimit if 4 bytes cannot be appended to the buffer.

func (*Static) ResizeBytes added in v0.32.0

func (s *Static) ResizeBytes(n int) []byte

ResizeBytes panics with ErrSizeLimit if n is larger than buffer capacity.

func (*Static) Write added in v0.32.0

func (s *Static) Write(b []byte) (n int, err error)

Write doesn't panic.

Jump to

Keyboard shortcuts

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