wire

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package wire provides hand-written protobuf wire-format encoding for Mumble protocol messages. Produces Mumble-compatible binary without using google.golang.org/protobuf.

Index

Constants

View Source
const (
	WireVarint          = 0
	WireFixed64         = 1
	WireLengthDelimited = 2
	WireFixed32         = 5
)

Wire types per protobuf spec

Variables

View Source
var (
	ErrBufferTooShort = errors.New("wire: buffer too short")
	ErrInvalidTag     = errors.New("wire: invalid tag")
)

Functions

func AppendBytes

func AppendBytes(b []byte, fieldNum int, data []byte) []byte

AppendBytes appends length-delimited bytes (field tag + length + data).

func AppendFixed32

func AppendFixed32(b []byte, v uint32) []byte

AppendFixed32 appends a little-endian uint32 (protobuf fixed32).

func AppendFixed64

func AppendFixed64(b []byte, v uint64) []byte

AppendFixed64 appends a little-endian uint64 (protobuf fixed64).

func AppendString

func AppendString(b []byte, fieldNum int, s string) []byte

AppendString appends a length-delimited string.

func AppendTag

func AppendTag(b []byte, fieldNum int, wireType int) []byte

AppendTag appends (fieldNum<<3)|wireType as a varint.

func AppendVarint

func AppendVarint(b []byte, v uint64) []byte

AppendVarint appends a standard protobuf varint.

func Float32bits

func Float32bits(f float32) uint32

Float32bits converts float32 to uint32 for wire encoding.

func Float32frombits

func Float32frombits(u uint32) float32

Float32frombits converts uint32 from wire to float32.

func ReadFixed32

func ReadFixed32(b []byte) uint32

ReadFixed32 reads a fixed32 from b. Caller must ensure len(b) >= 4.

func ReadFixed64

func ReadFixed64(b []byte) uint64

ReadFixed64 reads a fixed64 from b. Caller must ensure len(b) >= 8.

func ReadLengthDelimited

func ReadLengthDelimited(b []byte) ([]byte, int, error)

ReadLengthDelimited returns the length-delimited bytes and bytes consumed.

func ReadTag

func ReadTag(b []byte) (fieldNum int, wireType int, n int, err error)

ReadTag reads a tag (field num, wire type) and returns bytes consumed.

func ReadVarint

func ReadVarint(b []byte) (uint64, int, error)

ReadVarint reads a varint from b. Returns value and bytes consumed.

func SkipField

func SkipField(b []byte, wireType int) (int, error)

SkipField skips a field based on wire type. Returns bytes consumed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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