Help us shape the future of Go! Take the 2026 Go Developer Survey

pbf

package module
v0.0.0-...-3e9d29f Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: Apache-2.0 Imports: 2 Imported by: 12

README

pbf - Read protocol buffers using your own implementation

GoDoc

This project was designed to serialize protocol buffers structures from their type primitives. There are quite a few performance advantages to this including reduced allocation cost say if you protocol buffer structure is immediately tranformed into another data struture that whole protocol buffer allocation is sort of a waste.

Their our some functions in here that don't quite fit the scope of the project which I need to change but other than that, the functions for primitives (at least the ones I use) were labored over quite meticulously in regards to performance. If you would like to see an example of a reader I've implemented myself there is one here.

As you can see whats you understand the patters of pbfs its pretty straight forward, but more importantly if you have a really large structure of which 1000s need to be read, you can peak in and grab just the context or information you need in a custom read function.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeVarint

func DecodeVarint(buf []byte) (x uint64)

func DecodeVarint2

func DecodeVarint2(buf []byte) (x uint64, n int)

DecodeVarint reads a varint-encoded integer from the slice. It returns the integer and the number of bytes consumed, or zero if there is not enough. This is the format for the int32, int64, uint32, uint64, bool, and enum protocol buffer types.

func EncodeVarint

func EncodeVarint(x uint64) []byte

EncodeVarint returns the varint encoding of x. This is the format for the int32, int64, uint32, uint64, bool, and enum protocol buffer types. Not used by the package itself, but helpful to clients wishing to use the same encoding.

func Key

func Key(x byte) (byte, byte)

a much faster key integration (microseconds to nanoseconds) returns the value number and key number for a given byte

func ReadInt32

func ReadInt32(buf []byte) int32

func ReadInt64

func ReadInt64(bytes []byte) int64

reads a uint64 from a list of bytes

func ReadUInt32

func ReadUInt32(buf []byte) uint32

func ReadUint64

func ReadUint64(bytes []byte) uint64

reads a uint64 from a list of bytes

func Round

func Round(val float64, roundOn float64, places int) (newVal float64)

Types

type PBF

type PBF struct {
	Pbf    []byte
	Pos    int
	Length int
}

the structure used for implementing a custom reader

func NewPBF

func NewPBF(bytevals []byte) *PBF

func (*PBF) Byte

func (pbf *PBF) Byte()

show me the next 5 bytes

func (*PBF) ReadBool

func (pbf *PBF) ReadBool() bool

func (*PBF) ReadDouble

func (pbf *PBF) ReadDouble() float64

func (*PBF) ReadFixed32

func (pbf *PBF) ReadFixed32() uint32

func (*PBF) ReadFixed64

func (pbf *PBF) ReadFixed64() uint64

reads a uint64 from a list of bytes

func (*PBF) ReadFloat

func (pbf *PBF) ReadFloat() float32

func (*PBF) ReadInt32

func (pbf *PBF) ReadInt32() int32

read int32

func (*PBF) ReadInt64

func (pbf *PBF) ReadInt64() int64

func (*PBF) ReadKey

func (pbf *PBF) ReadKey() (byte, byte)

reads a key

func (*PBF) ReadPacked

func (pbf *PBF) ReadPacked() []uint32

an unused implemenation of readuint32

func (*PBF) ReadPackedInt32

func (pbf *PBF) ReadPackedInt32() []int32

small function to read a packed set of int32 tags

func (*PBF) ReadPackedUInt32

func (pbf *PBF) ReadPackedUInt32() []uint32

an old read packed uint32 impelementation

func (*PBF) ReadPackedUInt32_2

func (pbf *PBF) ReadPackedUInt32_2() []uint32

the current readpacked uint32 implemenation

func (*PBF) ReadPackedUInt32_3

func (pbf *PBF) ReadPackedUInt32_3() []uint32

an attempted readpackeduint implementation

func (*PBF) ReadPackedUInt64

func (pbf *PBF) ReadPackedUInt64() []int

small function to read a packed set of integers

func (*PBF) ReadSFixed32

func (pbf *PBF) ReadSFixed32() int32

func (*PBF) ReadSFixed64

func (pbf *PBF) ReadSFixed64() int64

reads a uint64 from a list of bytes

func (*PBF) ReadSVarint

func (pbf *PBF) ReadSVarint() float64

read s var int

func (*PBF) ReadSVarintPower

func (pbf *PBF) ReadSVarintPower() float64

read s varint with geobuf deltas

func (*PBF) ReadString

func (pbf *PBF) ReadString() string

func (*PBF) ReadUInt32

func (pbf *PBF) ReadUInt32() uint32

readuint32 implemenation

func (*PBF) ReadUInt64

func (pbf *PBF) ReadUInt64() uint64

func (*PBF) ReadUInt322

func (pbf *PBF) ReadUInt322() uint32

old reauint32 impolementation

func (*PBF) ReadVarint

func (pbf *PBF) ReadVarint() int

the definitive read var int implenation

func (*PBF) ReadVarint2

func (pbf *PBF) ReadVarint2() int

old read varint implementatino

func (*PBF) Varint

func (pbf *PBF) Varint() []byte

var int bytes

Jump to

Keyboard shortcuts

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