polyglot

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 20

README


Logo

Polyglot

A high-performance serialization framework used for encoding and decoding arbitrary datastructures across languages.

Discord Tests

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/loopholelabs/polyglot. For more contribution information check out the contribution guide.

License

The Polyglot project is available as open source under the terms of the Apache License, Version 2.0.

Code of Conduct

Everyone interacting in the Polyglot project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the CNCF Code of Conduct.

Project Managed By:

Documentation

Index

Constants

View Source
const (
	VarIntLen16 = 3
	VarIntLen32 = 5
	VarIntLen64 = 10
)

Variables

View Source
var (
	ErrInvalidSlice   = errors.New("invalid slice encoding")
	ErrInvalidMap     = errors.New("invalid map encoding")
	ErrInvalidBytes   = errors.New("invalid bytes encoding")
	ErrInvalidString  = errors.New("invalid string encoding")
	ErrInvalidError   = errors.New("invalid error encoding")
	ErrInvalidBool    = errors.New("invalid bool encoding")
	ErrInvalidUint8   = errors.New("invalid uint8 encoding")
	ErrInvalidUint16  = errors.New("invalid uint16 encoding")
	ErrInvalidUint32  = errors.New("invalid uint32 encoding")
	ErrInvalidUint64  = errors.New("invalid uint64 encoding")
	ErrInvalidInt32   = errors.New("invalid int32 encoding")
	ErrInvalidInt64   = errors.New("invalid int64 encoding")
	ErrInvalidFloat32 = errors.New("invalid float32 encoding")
	ErrInvalidFloat64 = errors.New("invalid float64 encoding")
)
View Source
var (
	NilRawKind     = byte(0)
	SliceRawKind   = byte(1)
	MapRawKind     = byte(2)
	AnyRawKind     = byte(3)
	BytesRawKind   = byte(4)
	StringRawKind  = byte(5)
	ErrorRawKind   = byte(6)
	BoolRawKind    = byte(7)
	Uint8RawKind   = byte(8)
	Uint16RawKind  = byte(9)
	Uint32RawKind  = byte(10)
	Uint64RawKind  = byte(11)
	Int32RawKind   = byte(12)
	Int64RawKind   = byte(13)
	Float32RawKind = byte(14)
	Float64RawKind = byte(15)
)
View Source
var (
	NilKind     = Kind(NilRawKind)
	SliceKind   = Kind(SliceRawKind)
	MapKind     = Kind(MapRawKind)
	AnyKind     = Kind(AnyRawKind)
	BytesKind   = Kind(BytesRawKind)
	StringKind  = Kind(StringRawKind)
	ErrorKind   = Kind(ErrorRawKind)
	BoolKind    = Kind(BoolRawKind)
	Uint8Kind   = Kind(Uint8RawKind)
	Uint16Kind  = Kind(Uint16RawKind)
	Uint32Kind  = Kind(Uint32RawKind)
	Uint64Kind  = Kind(Uint64RawKind)
	Int32Kind   = Kind(Int32RawKind)
	Int64Kind   = Kind(Int64RawKind)
	Float32Kind = Kind(Float32RawKind)
	Float64Kind = Kind(Float64RawKind)
)

Functions

func PutBuffer

func PutBuffer(b *Buffer)

Types

type Buffer

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

func GetBuffer

func GetBuffer() *Buffer

func NewBuffer

func NewBuffer() *Buffer

func NewBufferFromBytes added in v1.2.0

func NewBufferFromBytes(b []byte) *Buffer

func NewBufferSize added in v1.2.0

func NewBufferSize(size int) *Buffer

func (*Buffer) Bytes

func (buf *Buffer) Bytes() []byte

func (*Buffer) Cap added in v1.2.0

func (buf *Buffer) Cap() int

func (*Buffer) Grow added in v1.2.1

func (buf *Buffer) Grow(n int)

func (*Buffer) Len

func (buf *Buffer) Len() int

func (*Buffer) MoveOffset added in v1.2.0

func (buf *Buffer) MoveOffset(offset int)

func (*Buffer) Reset

func (buf *Buffer) Reset()

func (*Buffer) Write

func (buf *Buffer) Write(b []byte) int

type BufferDecoder added in v1.2.0

type BufferDecoder []byte

func Decoder

func Decoder(b []byte) *BufferDecoder

func (*BufferDecoder) Bool added in v1.2.0

func (d *BufferDecoder) Bool() (value bool, err error)

func (*BufferDecoder) Bytes added in v1.2.0

func (d *BufferDecoder) Bytes(b []byte) (value []byte, err error)

func (*BufferDecoder) Error added in v1.2.0

func (d *BufferDecoder) Error() (value, err error)

func (*BufferDecoder) Float32 added in v1.2.0

func (d *BufferDecoder) Float32() (value float32, err error)

func (*BufferDecoder) Float64 added in v1.2.0

func (d *BufferDecoder) Float64() (value float64, err error)

func (*BufferDecoder) Int32 added in v1.2.0

func (d *BufferDecoder) Int32() (value int32, err error)

func (*BufferDecoder) Int64 added in v1.2.0

func (d *BufferDecoder) Int64() (value int64, err error)

func (*BufferDecoder) Map added in v1.2.0

func (d *BufferDecoder) Map(keyKind, valueKind Kind) (size uint32, err error)

func (*BufferDecoder) Nil added in v1.2.0

func (d *BufferDecoder) Nil() (value bool)

func (*BufferDecoder) Slice added in v1.2.0

func (d *BufferDecoder) Slice(kind Kind) (size uint32, err error)

func (*BufferDecoder) String added in v1.2.0

func (d *BufferDecoder) String() (value string, err error)

func (*BufferDecoder) Uint16 added in v1.2.0

func (d *BufferDecoder) Uint16() (value uint16, err error)

func (*BufferDecoder) Uint32 added in v1.2.0

func (d *BufferDecoder) Uint32() (value uint32, err error)

func (*BufferDecoder) Uint64 added in v1.2.0

func (d *BufferDecoder) Uint64() (value uint64, err error)

func (*BufferDecoder) Uint8 added in v1.2.0

func (d *BufferDecoder) Uint8() (value uint8, err error)

type BufferEncoder

type BufferEncoder Buffer

func Encoder

func Encoder(b *Buffer) *BufferEncoder

func (*BufferEncoder) Bool

func (e *BufferEncoder) Bool(value bool) *BufferEncoder

func (*BufferEncoder) Bytes

func (e *BufferEncoder) Bytes(value []byte) *BufferEncoder

func (*BufferEncoder) Error

func (e *BufferEncoder) Error(value error) *BufferEncoder

func (*BufferEncoder) Float32

func (e *BufferEncoder) Float32(value float32) *BufferEncoder

func (*BufferEncoder) Float64

func (e *BufferEncoder) Float64(value float64) *BufferEncoder

func (*BufferEncoder) Int32

func (e *BufferEncoder) Int32(value int32) *BufferEncoder

func (*BufferEncoder) Int64

func (e *BufferEncoder) Int64(value int64) *BufferEncoder

func (*BufferEncoder) Map

func (e *BufferEncoder) Map(size uint32, keyKind, valueKind Kind) *BufferEncoder

func (*BufferEncoder) Nil

func (e *BufferEncoder) Nil() *BufferEncoder

func (*BufferEncoder) Slice

func (e *BufferEncoder) Slice(size uint32, kind Kind) *BufferEncoder

func (*BufferEncoder) String

func (e *BufferEncoder) String(value string) *BufferEncoder

func (*BufferEncoder) Uint16

func (e *BufferEncoder) Uint16(value uint16) *BufferEncoder

func (*BufferEncoder) Uint32

func (e *BufferEncoder) Uint32(value uint32) *BufferEncoder

func (*BufferEncoder) Uint64

func (e *BufferEncoder) Uint64(value uint64) *BufferEncoder

func (*BufferEncoder) Uint8

func (e *BufferEncoder) Uint8(value uint8) *BufferEncoder

type Error

type Error string

func (Error) Error

func (e Error) Error() string

func (Error) Is

func (e Error) Is(err error) bool

type Kind

type Kind byte

type Pool

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

func NewPool

func NewPool() *Pool

func (*Pool) Get

func (p *Pool) Get() (b *Buffer)

func (*Pool) Put

func (p *Pool) Put(b *Buffer)

Jump to

Keyboard shortcuts

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