internal

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ByteInputAdapterPool shared pool
	ByteInputAdapterPool = sync.Pool{
		New: func() interface{} {
			return &ByteInputAdapter{}
		},
	}

	// ByteBufferPool shared pool
	ByteBufferPool = sync.Pool{
		New: func() interface{} {
			return &ByteBuffer{}
		},
	}
)

Functions

This section is empty.

Types

type ByteBuffer

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

ByteBuffer raw bytes wrapper

func (*ByteBuffer) GetReadBytes

func (b *ByteBuffer) GetReadBytes() int64

GetReadBytes returns read bytes

func (*ByteBuffer) Next

func (b *ByteBuffer) Next(n int) ([]byte, error)

Next returns a slice containing the next n bytes from the reader If there are fewer bytes than the given n, io.ErrUnexpectedEOF will be returned

func (*ByteBuffer) ReadUInt16

func (b *ByteBuffer) ReadUInt16() (uint16, error)

ReadUInt16 reads uint16 with LittleEndian order

func (*ByteBuffer) ReadUInt32

func (b *ByteBuffer) ReadUInt32() (uint32, error)

ReadUInt32 reads uint32 with LittleEndian order

func (*ByteBuffer) Reset

func (b *ByteBuffer) Reset(buf []byte)

Reset resets the given buffer with a new byte slice

func (*ByteBuffer) SkipBytes

func (b *ByteBuffer) SkipBytes(n int) error

SkipBytes skips exactly n bytes

type ByteInput

type ByteInput interface {
	// Next returns a slice containing the next n bytes from the buffer,
	// advancing the buffer as if the bytes had been returned by Read.
	Next(n int) ([]byte, error)
	// ReadUInt32 reads uint32 with LittleEndian order
	ReadUInt32() (uint32, error)
	// ReadUInt16 reads uint16 with LittleEndian order
	ReadUInt16() (uint16, error)
	// GetReadBytes returns read bytes
	GetReadBytes() int64
	// SkipBytes skips exactly n bytes
	SkipBytes(n int) error
}

ByteInput typed interface around io.Reader or raw bytes

func NewByteInput

func NewByteInput(buf []byte) ByteInput

NewByteInput creates raw bytes wrapper

func NewByteInputFromReader

func NewByteInputFromReader(reader io.Reader) ByteInput

NewByteInputFromReader creates reader wrapper

type ByteInputAdapter

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

ByteInputAdapter reader wrapper

func (*ByteInputAdapter) GetReadBytes

func (b *ByteInputAdapter) GetReadBytes() int64

GetReadBytes returns read bytes

func (*ByteInputAdapter) Next

func (b *ByteInputAdapter) Next(n int) ([]byte, error)

Next returns a slice containing the next n bytes from the buffer, advancing the buffer as if the bytes had been returned by Read.

func (*ByteInputAdapter) ReadUInt16

func (b *ByteInputAdapter) ReadUInt16() (uint16, error)

ReadUInt16 reads uint16 with LittleEndian order

func (*ByteInputAdapter) ReadUInt32

func (b *ByteInputAdapter) ReadUInt32() (uint32, error)

ReadUInt32 reads uint32 with LittleEndian order

func (*ByteInputAdapter) Reset

func (b *ByteInputAdapter) Reset(stream io.Reader)

Reset resets the given buffer with a new stream

func (*ByteInputAdapter) SkipBytes

func (b *ByteInputAdapter) SkipBytes(n int) error

SkipBytes skips exactly n bytes

Jump to

Keyboard shortcuts

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