binary

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SizeOfUint8Bytes  = 1
	SizeOfUint16Bytes = 2
	SizeOfUint32Bytes = 4
	SizeOfUint64Bytes = 8
	SizeOfInt8Bytes   = 1
	SizeOfInt16Bytes  = 2
	SizeOfInt32Bytes  = 4
	SizeOfInt64Bytes  = 8
)

Numbers' bytes size.

Variables

View Source
var (
	ErrNotEnoughBytes      = NewProtocolError(nil, "not enough bytes available")
	ErrNotEnoughBytesWrite = NewProtocolError(nil, "not enough bytes available in buffer to write")
)

errors of parsing.

Functions

This section is empty.

Types

type Parser

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

Parser struct.

func NewParser

func NewParser(b binary.ByteOrder) Parser

NewParser constructor.

func (*Parser) ParseInt16

func (p *Parser) ParseInt16(b []byte) int16

func (*Parser) ParseInt32

func (p *Parser) ParseInt32(b []byte) int32

func (*Parser) ParseInt64

func (p *Parser) ParseInt64(b []byte) int64

func (*Parser) ParseInt8

func (p *Parser) ParseInt8(b []byte) int8

func (*Parser) ParseUint16

func (p *Parser) ParseUint16(b []byte) uint16

func (*Parser) ParseUint32

func (p *Parser) ParseUint32(b []byte) uint32

func (*Parser) ParseUint64

func (p *Parser) ParseUint64(b []byte) uint64

func (*Parser) ParseUint8

func (p *Parser) ParseUint8(b []byte) uint8

type ProtocolError

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

ProtocolError represents errors during protocol io.

func NewProtocolError

func NewProtocolError(inner error, msg string) *ProtocolError

NewProtocolError constructs a protocol error.

func (*ProtocolError) Error

func (r *ProtocolError) Error() string

Error function.

func (*ProtocolError) Unwrap

func (r *ProtocolError) Unwrap() error

Unwrap function.

type ReadBuffer

type ReadBuffer struct {
	Parser Parser
	// contains filtered or unexported fields
}

ReadBuffer struct.

func NewReadBuffer

func NewReadBuffer(rd io.Reader, bo binary.ByteOrder, size int) ReadBuffer

NewReadBuffer constructor.

func (*ReadBuffer) Buffered

func (rb *ReadBuffer) Buffered() int

func (*ReadBuffer) DiscardN

func (rb *ReadBuffer) DiscardN(n int) error

func (*ReadBuffer) Done

func (rb *ReadBuffer) Done() bool

func (*ReadBuffer) Peek

func (rb *ReadBuffer) Peek(n int) ([]byte, error)

func (*ReadBuffer) ReadMessage

func (rb *ReadBuffer) ReadMessage(size int64) ([]byte, error)

func (*ReadBuffer) ReadN

func (rb *ReadBuffer) ReadN(n int, f func([]byte)) error

func (*ReadBuffer) ReadUint16

func (rb *ReadBuffer) ReadUint16(v *uint16) error

func (*ReadBuffer) ReadUint32

func (rb *ReadBuffer) ReadUint32(v *uint32) error

func (*ReadBuffer) ReadUint64

func (rb *ReadBuffer) ReadUint64(v *uint64) error

func (*ReadBuffer) ReadUint8

func (rb *ReadBuffer) ReadUint8(v *uint8) error

func (*ReadBuffer) ReadVarString

func (rb *ReadBuffer) ReadVarString(size uint64) (string, error)

func (*ReadBuffer) ReadVarUInt

func (rb *ReadBuffer) ReadVarUInt(v *uint64) (remain int, err error)

func (*ReadBuffer) Remaining

func (rb *ReadBuffer) Remaining() int

func (*ReadBuffer) Reset

func (rb *ReadBuffer) Reset(r io.Reader)

func (*ReadBuffer) SnappyReader

func (rb *ReadBuffer) SnappyReader() *snappy.Reader

type WriteBuffer

type WriteBuffer struct {
	Writer bufio.Writer
	// contains filtered or unexported fields
}

WriteBuffer struct.

func NewWriteBuffer

func NewWriteBuffer(w io.Writer, binaryEndianness binary.ByteOrder) WriteBuffer

NewWriteBuffer constructor.

func (*WriteBuffer) Flush

func (wb *WriteBuffer) Flush() error

func (*WriteBuffer) Reset

func (wb *WriteBuffer) Reset(w io.Writer)

func (*WriteBuffer) Write

func (wb *WriteBuffer) Write(b []byte) (int, error)

func (*WriteBuffer) WriteString

func (wb *WriteBuffer) WriteString(s string) error

func (*WriteBuffer) WriteString8

func (wb *WriteBuffer) WriteString8(s string) error

func (*WriteBuffer) WriteUint16

func (wb *WriteBuffer) WriteUint16(i uint16) error

func (*WriteBuffer) WriteUint32

func (wb *WriteBuffer) WriteUint32(i uint32) error

func (*WriteBuffer) WriteUint64

func (wb *WriteBuffer) WriteUint64(i uint64) error

func (*WriteBuffer) WriteUint8

func (wb *WriteBuffer) WriteUint8(i uint8) error

Jump to

Keyboard shortcuts

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