gather

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package gather implements data structures storing binary data organized in a series of byte slices of fixed size that only gathered together by the user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpStats added in v0.9.0

func DumpStats(ctx context.Context)

DumpStats logs the allocator statistics.

Types

type Bytes

type Bytes struct {
	Slices [][]byte
	// contains filtered or unexported fields
}

Bytes represents a sequence of bytes split into slices.

func FromSlice

func FromSlice(b []byte) Bytes

FromSlice creates Bytes from the specified slice.

func (*Bytes) AppendSectionTo

func (b *Bytes) AppendSectionTo(w io.Writer, offset, size int) error

AppendSectionTo writes the section of the buffer to the provided writer.

func (Bytes) AppendToSlice added in v0.9.0

func (b Bytes) AppendToSlice(output []byte) []byte

AppendToSlice appends the contents to the provided slice.

func (Bytes) Length

func (b Bytes) Length() int

Length returns the combined length of all slices.

func (Bytes) ReadAt added in v0.9.0

func (b Bytes) ReadAt(p []byte, off int64) (n int, err error)

ReadAt implements io.ReaderAt interface.

func (Bytes) Reader

func (b Bytes) Reader() io.ReadSeekCloser

Reader returns a reader for the data.

func (Bytes) ToByteSlice added in v0.9.0

func (b Bytes) ToByteSlice() []byte

ToByteSlice returns contents as a newly-allocated byte slice.

func (Bytes) WriteTo

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

WriteTo writes contents to the specified writer and returns number of bytes written.

type WriteBuffer

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

WriteBuffer is a write buffer for content of unknown size that manages data in a series of byte slices of uniform size.

func NewWriteBuffer

func NewWriteBuffer() *WriteBuffer

NewWriteBuffer creates new write buffer.

func (*WriteBuffer) Append

func (b *WriteBuffer) Append(data []byte)

Append appends the specified slice of bytes to the buffer.

func (*WriteBuffer) AppendSectionTo added in v0.8.0

func (b *WriteBuffer) AppendSectionTo(w io.Writer, offset, size int) error

AppendSectionTo appends the section of the buffer to the provided slice and returns it.

func (*WriteBuffer) Bytes added in v0.8.0

func (b *WriteBuffer) Bytes() Bytes

Bytes returns inner gather.Bytes.

func (*WriteBuffer) Close

func (b *WriteBuffer) Close()

Close releases all memory allocated by this buffer.

func (*WriteBuffer) Dup added in v0.10.2

func (b *WriteBuffer) Dup() *WriteBuffer

Dup creates a clone of the WriteBuffer.

func (*WriteBuffer) Length added in v0.8.0

func (b *WriteBuffer) Length() int

Length returns the combined length of all slices.

func (*WriteBuffer) MakeContiguous added in v0.9.0

func (b *WriteBuffer) MakeContiguous(length int) []byte

MakeContiguous ensures the write buffer consists of exactly one contiguous single slice of the provided length and returns the slice.

func (*WriteBuffer) Reset

func (b *WriteBuffer) Reset()

Reset resets buffer back to empty.

func (*WriteBuffer) ToByteSlice added in v0.9.0

func (b *WriteBuffer) ToByteSlice() []byte

ToByteSlice appends all bytes to the provided slice and returns it.

func (*WriteBuffer) Write

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

Write implements io.Writer for appending to the buffer.

Jump to

Keyboard shortcuts

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