buffer

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2018 License: BSD-3-Clause Imports: 2 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")
)

Errors implementing interface{ BufferSizeLimit() string }.

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. The slice must be empty.

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. The slice must be empty.

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) PutUint32 added in v0.11.0

func (d *Dynamic) PutUint32(i uint32)

Extend 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. The slice must be empty.

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) PutUint32 added in v0.11.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.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, capacity int) Static

MakeStatic buffer. The slice must be empty, but it must be able to support the specified capacity.

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, capacity int) *Static

NewStatic buffer. The slice must be empty, but it must be able to support the specified capacity.

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) PutUint32 added in v0.11.0

func (s *Static) PutUint32(i uint32)

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

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