binary

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const NullString = 0xFB

MySQL: Text Resultset Row https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query_response_text_resultset_row.html NULL is sent as 0xFB

Variables

View Source
var ErrInvalid = errors.New("invalid")

ErrInvalid is returned when an invalid value is encountered.

View Source
var ErrNull = errors.New("null")

ErrNull is returned when a null value is encountered.

Functions

func BytesToDate

func BytesToDate(b []byte) (time.Time, error)

BytesToDate converts a date byte slice to a time.Time.

func BytesToDatetime

func BytesToDatetime(b []byte) (time.Time, error)

BytesToDatetime converts a datetime byte slice to a time.Time.

func BytesToDuration

func BytesToDuration(b []byte) (time.Duration, error)

BytesToTime converts a byte slice to a time.Time.

func BytesToFloat4

func BytesToFloat4(b []byte) (float32, error)

BytesToFloat4 converts the specified byte array to a float32.

func BytesToFloat8

func BytesToFloat8(b []byte) (float64, error)

BytesToFloat8 converts the specified byte array to a float64.

func BytesToInt1

func BytesToInt1(b []byte) (int8, error)

BytesToInt1 converts the specified byte array to an integer.

func BytesToInt2

func BytesToInt2(b []byte) (int16, error)

BytesToInt2 converts the specified byte array to an integer.

func BytesToInt3

func BytesToInt3(b []byte) (int32, error)

BytesToInt3 converts the specified byte array to an integer.

func BytesToInt4

func BytesToInt4(b []byte) (int32, error)

BytesToInt4 converts the specified byte array to an integer.

func BytesToInt8

func BytesToInt8(b []byte) (int64, error)

BytesToInt8 converts the specified byte array to an integer.

func BytesToTime

func BytesToTime(b []byte) (time.Time, error)

BytesToTime converts a byte slice to a time.Time.

func BytesToUint1

func BytesToUint1(b []byte) (uint8, error)

BytesToUint8 converts the specified byte array to an integer.

func BytesToUint2

func BytesToUint2(b []byte) (uint16, error)

BytesToUint2 converts the specified byte array to an integer.

func BytesToUint3

func BytesToUint3(b []byte) (uint32, error)

BytesToUint3 converts the specified byte array to an integer.

func BytesToUint4

func BytesToUint4(b []byte) (uint32, error)

BytesToUint4 converts the specified byte array to an integer.

func BytesToUint8

func BytesToUint8(b []byte) (uint64, error)

BytesToUint8 converts the specified byte array to an integer.

func DurationToTimeBytes

func DurationToTimeBytes(d time.Duration) []byte

TimeToDatetimeBytes converts a time.Time to a datetime byte slice.

func Float4ToBytes

func Float4ToBytes(v float32) []byte

Float4ToBytes converts the specified float32 to a byte array.

func Float8ToBytes

func Float8ToBytes(v float64) []byte

Float8ToBytes converts the specified float64 to a byte array.

func Int1ToBytes

func Int1ToBytes(v int8) []byte

Int1ToBytes converts the specified integer to a byte array.

func Int2ToBytes

func Int2ToBytes(v int16) []byte

Int2ToBytes converts the specified integer to a byte array.

func Int3ToBytes

func Int3ToBytes(v int32) []byte

Int3ToBytes converts the specified integer to a byte array.

func Int4ToBytes

func Int4ToBytes(v int32) []byte

Int4ToBytes converts the specified integer to a byte array.

func Int8ToBytes

func Int8ToBytes(v int64) []byte

Int8ToBytes converts the specified integer to a byte array.

func LengthEncodeIntSize

func LengthEncodeIntSize(v uint64) int

LengthEncodeIntSize returns the size of a length encoded integer.

func LengthEncodedStringToString

func LengthEncodedStringToString(s string) []byte

func TimeToDateBytes

func TimeToDateBytes(t time.Time) []byte

TimeToDatetimeBytes converts a time.Time to a datetime byte slice.

func TimeToDatetimeBytes

func TimeToDatetimeBytes(t time.Time) []byte

TimeToDatetimeBytes converts a time.Time to a datetime byte slice.

func Uint1ToBytes

func Uint1ToBytes(v uint8) []byte

Uint1ToBytes converts the specified integer to a byte array.

func Uint2ToBytes

func Uint2ToBytes(v uint16) []byte

Uint2ToBytes converts the specified integer to a byte array.

func Uint3ToBytes

func Uint3ToBytes(v uint32) []byte

Uint3ToBytes converts the specified integer to a byte array.

func Uint4ToBytes

func Uint4ToBytes(v uint32) []byte

Uint4ToBytes converts the specified integer to a byte array.

func Uint8ToBytes

func Uint8ToBytes(v uint64) []byte

Uint8ToBytes converts the specified integer to a byte array.

Types

type Reader

type Reader struct {
	io.Reader
	// contains filtered or unexported fields
}

Reader represents a packet reader.

func NewReaderWithBytes

func NewReaderWithBytes(buf []byte) *Reader

NewReaderWithBytes returns a new packet reader with the specified byte array.

func NewReaderWithReader

func NewReaderWithReader(reader io.Reader) *Reader

NewReaderWithReader returns a new packet reader with the specified reader.

func (*Reader) PeekByte

func (reader *Reader) PeekByte() (uint8, error)

PeekByte peeks a byte.

func (*Reader) PeekBytes

func (reader *Reader) PeekBytes(n int) ([]byte, error)

PeekBytes peeks a byte array.

func (*Reader) PeekInt1

func (reader *Reader) PeekInt1() (uint8, error)

PeekInt1 peeks a 8-bit integer.

func (*Reader) PeekInt2

func (reader *Reader) PeekInt2() (uint16, error)

PeekInt2 reads a 16-bit integer.

func (*Reader) PeekInt4

func (reader *Reader) PeekInt4() (uint32, error)

PeekInt4 peeks a 32-bit integer.

func (*Reader) ReadByte

func (reader *Reader) ReadByte() (byte, error)

ReadByte reads a byte.

func (*Reader) ReadBytes

func (reader *Reader) ReadBytes(buf []byte) (int, error)

ReadBytes reads a byte array.

func (*Reader) ReadBytesUntil

func (reader *Reader) ReadBytesUntil(delim byte) ([]byte, error)

ReadBytesUntil reads a byte array until the specified delimiter.

func (*Reader) ReadEOFTerminatedString

func (reader *Reader) ReadEOFTerminatedString() (string, error)

ReadEOFTerminatedString reads a string until EOF.

func (*Reader) ReadFixedLengthBytes

func (reader *Reader) ReadFixedLengthBytes(n int) ([]byte, error)

ReadFixedLengthBytes reads a fixed bytes.

func (*Reader) ReadFixedLengthString

func (reader *Reader) ReadFixedLengthString(n int) (string, error)

ReadFixedLengthString reads a fixd string.

func (*Reader) ReadInt1

func (reader *Reader) ReadInt1() (uint8, error)

ReadInt1 peeks a 8-bit integer.

func (*Reader) ReadInt2

func (reader *Reader) ReadInt2() (uint16, error)

ReadInt2 reads a 16-bit integer.

func (*Reader) ReadInt3

func (reader *Reader) ReadInt3() (uint32, error)

ReadInt3 reads a 24-bit integer.

func (*Reader) ReadInt4

func (reader *Reader) ReadInt4() (uint32, error)

ReadInt4 reads a 32-bit integer.

func (*Reader) ReadInt8

func (reader *Reader) ReadInt8() (uint64, error)

ReadInt8 reads a 64-bit integer.

func (*Reader) ReadLengthEncodedBytes

func (reader *Reader) ReadLengthEncodedBytes() ([]byte, error)

ReadLengthEncodedBytes reads a length encoded bytes.

func (*Reader) ReadLengthEncodedInt

func (reader *Reader) ReadLengthEncodedInt() (uint64, error)

ReadLengthEncodedInt reads a length encoded integer.

func (*Reader) ReadLengthEncodedString

func (reader *Reader) ReadLengthEncodedString() (string, error)

ReadLengthEncodedInt reads a length encoded integer.

func (*Reader) ReadNBytes

func (reader *Reader) ReadNBytes(n int) ([]byte, error)

ReadNBytes reads the specified number of bytes.

func (*Reader) ReadNullTerminatedBytes

func (reader *Reader) ReadNullTerminatedBytes() ([]byte, error)

ReadNullTerminatedString reads a string until NULL.

func (*Reader) ReadNullTerminatedString

func (reader *Reader) ReadNullTerminatedString() (string, error)

ReadNullTerminatedString reads a string until NULL.

func (*Reader) ReadTextResultsetRowString added in v1.3.1

func (reader *Reader) ReadTextResultsetRowString() (*string, error)

ReadTextResultsetRowString reads a string from the result set row.

func (*Reader) ReadVariableLengthString

func (reader *Reader) ReadVariableLengthString(n int) (string, error)

ReadVariableLengthString reads a string.

func (*Reader) SkipBytes

func (reader *Reader) SkipBytes(n int) error

type Writer

type Writer struct {
	bytes.Buffer
}

func NewWriter

func NewWriter() *Writer

NewWriter returns a new Writer.

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

Bytes returns the written bytes.

func (*Writer) WriteByte

func (w *Writer) WriteByte(b byte) error

WriteByte writes a byte.

func (*Writer) WriteBytes

func (w *Writer) WriteBytes(b []byte) (int, error)

WriteBytes writes a byte array.

func (*Writer) WriteEOFTerminatedString

func (w *Writer) WriteEOFTerminatedString(s string) error

WriteEOFTerminatedString writes a EOF terminated string.

func (*Writer) WriteFixedLengthBytes

func (w *Writer) WriteFixedLengthBytes(b []byte, n int) error

WriteFixedLengthString writes a fixed length bytes.

func (*Writer) WriteFixedLengthNullBytes

func (w *Writer) WriteFixedLengthNullBytes(n int) error

WriteFixedLengthNullBytes writes a fixed length null bytes.

func (*Writer) WriteFixedLengthString

func (w *Writer) WriteFixedLengthString(s string, n int) error

WriteFixedLengthString writes a fixed length string.

func (*Writer) WriteInt1

func (w *Writer) WriteInt1(v uint8) error

WriteInt1 writes a 1 byte integer.

func (*Writer) WriteInt2

func (w *Writer) WriteInt2(v uint16) error

WriteInt2 writes a 2 byte integer.

func (*Writer) WriteInt3

func (w *Writer) WriteInt3(v uint32) error

WriteInt3 writes a 3 byte integer.

func (*Writer) WriteInt4

func (w *Writer) WriteInt4(v uint32) error

WriteInt4 writes a 4 byte integer.

func (*Writer) WriteInt8

func (w *Writer) WriteInt8(v uint64) error

WriteInt8 writes a 64-bit integer.

func (*Writer) WriteLengthEncodedBytes

func (w *Writer) WriteLengthEncodedBytes(b []byte) error

WriteLengthEncodedBytes writes a length encoded bytes.

func (*Writer) WriteLengthEncodedInt

func (w *Writer) WriteLengthEncodedInt(v uint64) error

WriteLengthEncodedInt writes a length encoded integer.

func (*Writer) WriteLengthEncodedString

func (w *Writer) WriteLengthEncodedString(s string) error

WriteLengthEncodedString writes a length encoded string.

func (*Writer) WriteNullString added in v1.3.1

func (w *Writer) WriteNullString() error

WriteNullString writes a NULL string (0xFB) to the writer.

func (*Writer) WriteNullTerminatedBytes

func (w *Writer) WriteNullTerminatedBytes(b []byte) error

WriteNullTerminatedBytes writes a null terminated bytes.

func (*Writer) WriteNullTerminatedString

func (w *Writer) WriteNullTerminatedString(s string) error

WriteNullTerminatedString writes a null terminated string.

func (*Writer) WriteTextResultsetRowString added in v1.3.1

func (w *Writer) WriteTextResultsetRowString(s *string) error

WriteTextResultsetRow writes a text resultset row.

Jump to

Keyboard shortcuts

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