bytesutil

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: Apache-2.0 Imports: 7 Imported by: 118

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resize

func Resize(b []byte, n int) []byte

Resize resizes b to n bytes and returns b (which may be newly allocated).

func ToUnsafeBytes

func ToUnsafeBytes(s string) (b []byte)

ToUnsafeBytes converts s to a byte slice without memory allocations.

The returned byte slice is valid only until s is reachable and unmodified.

func ToUnsafeString

func ToUnsafeString(b []byte) string

ToUnsafeString converts b to string without memory allocations.

The returned string is valid only until b is reachable and unmodified.

Types

type ByteBuffer

type ByteBuffer struct {
	// B is the underlying byte slice.
	B []byte
}

ByteBuffer implements a simple byte buffer.

func (*ByteBuffer) MustClose

func (bb *ByteBuffer) MustClose()

MustClose closes bb for subsequent re-use.

func (*ByteBuffer) MustReadAt added in v1.33.0

func (bb *ByteBuffer) MustReadAt(p []byte, offset int64)

MustReadAt reads len(p) bytes starting from the given offset.

func (*ByteBuffer) NewReader

func (bb *ByteBuffer) NewReader() filestream.ReadCloser

NewReader returns new reader for the given bb.

func (*ByteBuffer) ReadFrom added in v1.20.2

func (bb *ByteBuffer) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads all the data from r to bb until EOF.

func (*ByteBuffer) Reset

func (bb *ByteBuffer) Reset()

Reset resets bb.

func (*ByteBuffer) Write

func (bb *ByteBuffer) Write(p []byte) (int, error)

Write appends p to bb.

type ByteBufferPool

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

ByteBufferPool is a pool of ByteBuffers.

func (*ByteBufferPool) Get

func (bbp *ByteBufferPool) Get() *ByteBuffer

Get obtains a ByteBuffer from bbp.

func (*ByteBufferPool) Put

func (bbp *ByteBufferPool) Put(bb *ByteBuffer)

Put puts bb into bbp.

Jump to

Keyboard shortcuts

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