fastmsg

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package fastmsg provides Go implementation of the fastmsg Message class

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

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

Message represents a packed data buffer. It is used for both serializing and deserializing data. All numbers are stored in little-endian byte order.

func NewMessage

func NewMessage() *Message

NewMessage creates a new Message instance for serializing data.

func NewMessageFromBuffer

func NewMessageFromBuffer(buffer []byte) *Message

NewMessageFromBuffer creates a new Message instance from a buffer for deserializing data.

func (*Message) AddBytes

func (m *Message) AddBytes(bytes []byte) *Message

AddBytes adds a byte slice to the message buffer. The byte slice is prefixed with its length as a uint32.

func (*Message) AddInt16

func (m *Message) AddInt16(value int16) *Message

AddInt16 adds an int16 to the message buffer.

func (*Message) AddInt32

func (m *Message) AddInt32(value int32) *Message

AddInt32 adds an int32 to the message buffer.

func (*Message) AddInt64

func (m *Message) AddInt64(value int64) *Message

AddInt64 adds an int64 to the message buffer.

func (*Message) AddInt8

func (m *Message) AddInt8(b int8) *Message

AddInt8 adds an int8 to the message buffer.

func (*Message) AddMessage

func (m *Message) AddMessage(message *Message) *Message

AddMessage adds a Message to the message buffer. The Message is prefixed with its length as a uint32.

func (*Message) AddString

func (m *Message) AddString(str string) *Message

AddString adds a string to the message buffer. The string is prefixed with its length as a uint32.

func (*Message) AddUInt16

func (m *Message) AddUInt16(value uint16) *Message

AddUInt16 adds a uint16 to the message buffer.

func (*Message) AddUInt32

func (m *Message) AddUInt32(value uint32) *Message

AddUInt32 adds a uint32 to the message buffer.

func (*Message) AddUInt64

func (m *Message) AddUInt64(value uint64) *Message

AddUInt64 adds a uint64 to the message buffer.

func (*Message) AddUInt8

func (m *Message) AddUInt8(b uint8) *Message

AddUInt8 adds a uint8 to the message buffer.

func (*Message) Clear

func (m *Message) Clear() *Message

Clear clears the message buffer.

func (*Message) ReadBytes

func (m *Message) ReadBytes() []byte

ReadBytes reads a byte slice from the message buffer and advances the cursor. If there's not enough data to read, it returns nil.

func (*Message) ReadInt16

func (m *Message) ReadInt16() int16

ReadInt16 reads an int16 from the message buffer and advances the cursor. If there's not enough data to read, it returns 0.

func (*Message) ReadInt32

func (m *Message) ReadInt32() int32

ReadInt32 reads an int32 from the message buffer and advances the cursor. If there's not enough data to read, it returns 0.

func (*Message) ReadInt64

func (m *Message) ReadInt64() int64

ReadInt64 reads an int64 from the message buffer and advances the cursor. If there's not enough data to read, it returns 0.

func (*Message) ReadInt8

func (m *Message) ReadInt8() int8

ReadInt8 reads an int8 from the message buffer and advances the cursor. If there's not enough data to read, it returns 0.

func (*Message) ReadMessage

func (m *Message) ReadMessage() *Message

ReadMessage reads a Message from the message buffer and advances the cursor. If there's not enough data to read, it returns nil.

func (*Message) ReadString

func (m *Message) ReadString() string

ReadString reads a string from the message buffer and advances the cursor. If there's not enough data to read, it returns an empty string.

func (*Message) ReadUInt16

func (m *Message) ReadUInt16() uint16

ReadUInt16 reads a uint16 from the message buffer and advances the cursor. If there's not enough data to read, it returns 0.

func (*Message) ReadUInt32

func (m *Message) ReadUInt32() uint32

ReadUInt32 reads a uint32 from the message buffer and advances the cursor. If there's not enough data to read, it returns 0.

func (*Message) ReadUInt64

func (m *Message) ReadUInt64() uint64

ReadUInt64 reads a uint64 from the message buffer and advances the cursor. If there's not enough data to read, it returns 0.

func (*Message) ReadUInt8

func (m *Message) ReadUInt8() uint8

ReadUInt8 reads a uint8 from the message buffer and advances the cursor. If there's not enough data to read, it returns 0.

func (*Message) Reset

func (m *Message) Reset()

Reset sets deserialization cursor to the beginning of the message buffer. All Read* methods advance the cursor, so Reset can be used to read the message again.

func (*Message) Seal

func (m *Message) Seal() []byte

Seal returns the serialized message buffer.

Jump to

Keyboard shortcuts

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