binaryutil

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: LGPL-2.1 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

BytesPool 字节对象池,用于减少GC提高编解码性能

View Source
var (
	// ErrInvalidSeekPos 调整的位置无效
	ErrInvalidSeekPos = errors.New("invalid seek position")
)
View Source
var (
	ErrLimitReached = errors.New("i/o limit reached")
)

Functions

func ReadFrom

func ReadFrom[T io.Reader](bs *ByteStream, reader T) (int64, error)

func SizeofBool

func SizeofBool() int

func SizeofByte

func SizeofByte() int

func SizeofBytes

func SizeofBytes(v []byte) int

func SizeofBytes128

func SizeofBytes128() int

func SizeofBytes16

func SizeofBytes16() int

func SizeofBytes160

func SizeofBytes160() int

func SizeofBytes256

func SizeofBytes256() int

func SizeofBytes32

func SizeofBytes32() int

func SizeofBytes512

func SizeofBytes512() int

func SizeofBytes64

func SizeofBytes64() int

func SizeofDouble

func SizeofDouble() int

func SizeofFloat

func SizeofFloat() int

func SizeofInt16

func SizeofInt16() int

func SizeofInt32

func SizeofInt32() int

func SizeofInt64

func SizeofInt64() int

func SizeofInt8

func SizeofInt8() int

func SizeofString

func SizeofString(v string) int

func SizeofUint16

func SizeofUint16() int

func SizeofUint32

func SizeofUint32() int

func SizeofUint64

func SizeofUint64() int

func SizeofUint8

func SizeofUint8() int

func SizeofUvarint

func SizeofUvarint(v uint64) int

func SizeofVarint

func SizeofVarint(v int64) int

Types

type ByteStream

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

func NewBigEndianStream

func NewBigEndianStream(p []byte) ByteStream

func NewByteStream

func NewByteStream(p []byte, endian binary.ByteOrder) ByteStream

func NewLittleEndianStream

func NewLittleEndianStream(p []byte) ByteStream

func (*ByteStream) BuffRead

func (s *ByteStream) BuffRead() []byte

func (*ByteStream) BuffUnread

func (s *ByteStream) BuffUnread() []byte

func (*ByteStream) BuffUnwritten

func (s *ByteStream) BuffUnwritten() []byte

func (*ByteStream) BuffWritten

func (s *ByteStream) BuffWritten() []byte

func (*ByteStream) BytesRead

func (s *ByteStream) BytesRead() int

func (*ByteStream) BytesUnread

func (s *ByteStream) BytesUnread() int

func (*ByteStream) BytesUnwritten

func (s *ByteStream) BytesUnwritten() int

func (*ByteStream) BytesWritten

func (s *ByteStream) BytesWritten() int

func (*ByteStream) ReadBool

func (s *ByteStream) ReadBool() (bool, error)

func (*ByteStream) ReadByte

func (s *ByteStream) ReadByte() (byte, error)

func (*ByteStream) ReadBytes

func (s *ByteStream) ReadBytes() ([]byte, error)

func (*ByteStream) ReadBytes128

func (s *ByteStream) ReadBytes128() ([128]byte, error)

func (*ByteStream) ReadBytes16

func (s *ByteStream) ReadBytes16() ([16]byte, error)

func (*ByteStream) ReadBytes160

func (s *ByteStream) ReadBytes160() ([160]byte, error)

func (*ByteStream) ReadBytes256

func (s *ByteStream) ReadBytes256() ([256]byte, error)

func (*ByteStream) ReadBytes32

func (s *ByteStream) ReadBytes32() ([32]byte, error)

func (*ByteStream) ReadBytes512

func (s *ByteStream) ReadBytes512() ([512]byte, error)

func (*ByteStream) ReadBytes64

func (s *ByteStream) ReadBytes64() ([64]byte, error)

func (*ByteStream) ReadBytesRef

func (s *ByteStream) ReadBytesRef() ([]byte, error)

func (*ByteStream) ReadDouble

func (s *ByteStream) ReadDouble() (float64, error)

func (*ByteStream) ReadFloat

func (s *ByteStream) ReadFloat() (float32, error)

func (*ByteStream) ReadFrom

func (s *ByteStream) ReadFrom(reader io.Reader) (int64, error)

func (*ByteStream) ReadInt16

func (s *ByteStream) ReadInt16() (int16, error)

func (*ByteStream) ReadInt32

func (s *ByteStream) ReadInt32() (int32, error)

func (*ByteStream) ReadInt64

func (s *ByteStream) ReadInt64() (int64, error)

func (*ByteStream) ReadInt8

func (s *ByteStream) ReadInt8() (int8, error)

func (*ByteStream) ReadString

func (s *ByteStream) ReadString() (string, error)

func (*ByteStream) ReadStringRef

func (s *ByteStream) ReadStringRef() (string, error)

func (*ByteStream) ReadUint16

func (s *ByteStream) ReadUint16() (uint16, error)

func (*ByteStream) ReadUint32

func (s *ByteStream) ReadUint32() (uint32, error)

func (*ByteStream) ReadUint64

func (s *ByteStream) ReadUint64() (uint64, error)

func (*ByteStream) ReadUint8

func (s *ByteStream) ReadUint8() (uint8, error)

func (*ByteStream) ReadUvarint

func (s *ByteStream) ReadUvarint() (uint64, error)

func (*ByteStream) ReadVarint

func (s *ByteStream) ReadVarint() (int64, error)

func (*ByteStream) SeekReadPos

func (s *ByteStream) SeekReadPos(p int) error

func (*ByteStream) SeekWritePos

func (s *ByteStream) SeekWritePos(p int) error

func (*ByteStream) WriteBool

func (s *ByteStream) WriteBool(v bool) error

func (*ByteStream) WriteByte

func (s *ByteStream) WriteByte(v byte) error

func (*ByteStream) WriteBytes

func (s *ByteStream) WriteBytes(v []byte) error

func (*ByteStream) WriteBytes128

func (s *ByteStream) WriteBytes128(v []byte) error

func (*ByteStream) WriteBytes16

func (s *ByteStream) WriteBytes16(v []byte) error

func (*ByteStream) WriteBytes160

func (s *ByteStream) WriteBytes160(v []byte) error

func (*ByteStream) WriteBytes256

func (s *ByteStream) WriteBytes256(v []byte) error

func (*ByteStream) WriteBytes32

func (s *ByteStream) WriteBytes32(v []byte) error

func (*ByteStream) WriteBytes512

func (s *ByteStream) WriteBytes512(v []byte) error

func (*ByteStream) WriteBytes64

func (s *ByteStream) WriteBytes64(v []byte) error

func (*ByteStream) WriteDouble

func (s *ByteStream) WriteDouble(v float64) error

func (*ByteStream) WriteFloat

func (s *ByteStream) WriteFloat(v float32) error

func (*ByteStream) WriteInt16

func (s *ByteStream) WriteInt16(v int16) error

func (*ByteStream) WriteInt32

func (s *ByteStream) WriteInt32(v int32) error

func (*ByteStream) WriteInt64

func (s *ByteStream) WriteInt64(v int64) error

func (*ByteStream) WriteInt8

func (s *ByteStream) WriteInt8(v int8) error

func (*ByteStream) WriteString

func (s *ByteStream) WriteString(v string) error

func (*ByteStream) WriteTo

func (s *ByteStream) WriteTo(writer io.Writer) (int64, error)

func (*ByteStream) WriteUint16

func (s *ByteStream) WriteUint16(v uint16) error

func (*ByteStream) WriteUint32

func (s *ByteStream) WriteUint32(v uint32) error

func (*ByteStream) WriteUint64

func (s *ByteStream) WriteUint64(v uint64) error

func (*ByteStream) WriteUint8

func (s *ByteStream) WriteUint8(v uint8) error

func (*ByteStream) WriteUvarint

func (s *ByteStream) WriteUvarint(v uint64) error

func (*ByteStream) WriteVarint

func (s *ByteStream) WriteVarint(v int64) error

type BytesWriter

type BytesWriter struct {
	N     int
	Bytes []byte
}

BytesWriter will only write bytes to the underlying writer until the limit is reached.

func NewBytesWriter

func NewBytesWriter(bs []byte) *BytesWriter

NewBytesWriter creates a new instance of BytesWriter.

func (*BytesWriter) Write

func (l *BytesWriter) Write(p []byte) (int, error)

Write implements io.Writer

type LimitWriter

type LimitWriter struct {
	Limit int
	N     int
	W     io.Writer
}

LimitWriter will only write bytes to the underlying writer until the limit is reached.

func NewLimitWriter

func NewLimitWriter(w io.Writer, n int) *LimitWriter

NewLimitWriter creates a new instance of LimitWriter.

func (*LimitWriter) Write

func (l *LimitWriter) Write(p []byte) (int, error)

Write implements io.Writer

type RecycleBytes

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

RecycleBytes 可回收字节对象

func MakeNonRecycleBytes

func MakeNonRecycleBytes(bytes []byte) RecycleBytes

MakeNonRecycleBytes 创建不可回收字节对象

func MakeRecycleBytes

func MakeRecycleBytes(bytes []byte) RecycleBytes

MakeRecycleBytes 创建可回收字节对象

func SliceRecycleBytes

func SliceRecycleBytes(bytes RecycleBytes, low, high int) RecycleBytes

SliceRecycleBytes 切片操作字节对象

func (RecycleBytes) Data

func (b RecycleBytes) Data() []byte

Data 数据

func (RecycleBytes) Recyclable

func (b RecycleBytes) Recyclable() bool

Recyclable 可否回收

func (RecycleBytes) Release

func (b RecycleBytes) Release()

Release 释放字节对象

Jump to

Keyboard shortcuts

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