wag: github.com/tsavola/wag/buffer Index | Files

package buffer

import "github.com/tsavola/wag/buffer"

Package buffer implements compile.CodeBuffer and compile.DataBuffer.

Index

Package Files

dynamic.go limited.go sizeerror.go static.go

Variables

var ErrSizeLimit error = err{}

type Dynamic Uses

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

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

func MakeDynamic Uses

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 Uses

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 Uses

func NewDynamic(b []byte) *Dynamic

NewDynamic buffer.

func NewDynamicHint Uses

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 Uses

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

Bytes doesn't panic.

func (*Dynamic) Extend Uses

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

Extend doesn't panic unless out of memory.

func (*Dynamic) Len Uses

func (d *Dynamic) Len() int

Len doesn't panic.

func (*Dynamic) PutByte Uses

func (d *Dynamic) PutByte(value byte)

PutBytes doesn't panic unless out of memory.

func (*Dynamic) PutUint32 Uses

func (d *Dynamic) PutUint32(i uint32)

Extend doesn't panic unless out of memory.

func (*Dynamic) ResizeBytes Uses

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

ResizeBytes doesn't panic unless out of memory.

type Limited Uses

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 Uses

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 Uses

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

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

func (*Limited) Bytes Uses

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

Bytes doesn't panic.

func (*Limited) Extend Uses

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

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

func (*Limited) Len Uses

func (l *Limited) Len() int

Len doesn't panic.

func (*Limited) PutByte Uses

func (l *Limited) PutByte(value byte)

PutByte panicks with ErrSizeLimit if the buffer is already full.

func (*Limited) PutUint32 Uses

func (l *Limited) PutUint32(i uint32)

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

func (*Limited) ResizeBytes Uses

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

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

type Static Uses

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 Uses

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 Uses

func NewStatic(b []byte) *Static

NewStatic buffer.

func (*Static) Bytes Uses

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

Bytes doesn't panic.

func (*Static) Cap Uses

func (s *Static) Cap() int

Capacity of the static buffer.

func (*Static) Extend Uses

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

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

func (*Static) Len Uses

func (s *Static) Len() int

Len doesn't panic.

func (*Static) PutByte Uses

func (s *Static) PutByte(value byte)

PutByte panicks with ErrSizeLimit if the buffer is already full.

func (*Static) PutUint32 Uses

func (s *Static) PutUint32(i uint32)

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

func (*Static) ResizeBytes Uses

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

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

func (*Static) Write Uses

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

Write doesn't panic.

Package buffer imports 3 packages (graph) and is imported by 5 packages. Updated 2019-11-15. Refresh now. Tools for package owners.