buffer

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package buffer implements compile.CodeBuffer and compile.DataBuffer.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSizeLimit  = sizeError("buffer size limit exceeded")
	ErrStaticSize = sizeError("static buffer capacity exceeded")
)

These errors implement interface{ OutputSizeLimit() bool }.

Functions

This section is empty.

Types

type Dynamic added in v0.8.0

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

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

func NewDynamic added in v0.8.0

func NewDynamic(b []byte) *Dynamic

NewDynamic buffer is initially empty (b is truncated).

func NewDynamicHint added in v0.8.0

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

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

func (*Dynamic) Bytes added in v0.8.0

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

Bytes doesn't panic.

func (*Dynamic) Extend added in v0.8.0

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

Extend doesn't panic unless out of memory.

func (*Dynamic) PutByte added in v0.8.0

func (d *Dynamic) PutByte(value byte)

PutBytes doesn't panic unless out of memory.

func (*Dynamic) ResizeBytes added in v0.8.0

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

ResizeBytes doesn't panic unless out of memory.

type Limited added in v0.8.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 NewLimited added in v0.8.0

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

NewLimited buffer with a maximum size. It is initially empty (b is truncated).

func (*Limited) Bytes added in v0.8.0

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

Bytes doesn't panic.

func (*Limited) Extend added in v0.8.0

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

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

func (*Limited) PutByte added in v0.8.0

func (l *Limited) PutByte(value byte)

PutByte panics with ErrSizeLimit if the buffer is already full.

func (*Limited) ResizeBytes added in v0.8.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.8.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.8.0

func MakeStatic(b []byte) Static

MakeStatic buffer with len(b) as its capacity. It is initially empty (b is truncated).

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

func NewStatic added in v0.8.0

func NewStatic(b []byte) *Static

NewStatic buffer with len(b) as its capacity. It is initially empty (b is truncated).

func (*Static) Bytes added in v0.8.0

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

Bytes doesn't panic.

func (*Static) Cap added in v0.8.0

func (s *Static) Cap() int

Capacity of the static buffer.

func (*Static) Extend added in v0.8.0

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

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

func (*Static) PutByte added in v0.8.0

func (s *Static) PutByte(value byte)

PutByte panics with ErrStaticSize if the buffer is already full.

func (*Static) ResizeBytes added in v0.8.0

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

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

Jump to

Keyboard shortcuts

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