benc

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 2 Imported by: 6

README

Benc

go workflow go report card go reference

The fastest serializer in pure Golang, with the option for backward/forward compatibile generated code.

This module is split into four main packages:

  • cmd/bencgen - the code-generator for benc
  • impl/gen - the implementation for bencgen, for handling backward and forward compatibility
  • std - the benc standard, raw serialization
  • idv - the benc ID validation, raw serialization with ID prefixing
Security
Benchmarks
benc.go

benc.go provides methods to do buffer reusing and to verify the marshal/unmarshal process.

License

MIT

Documentation

Index

Constants

View Source
const (
	Bytes2 int = 2
	Bytes4 int = 4
	Bytes8 int = 8
)

Variables

View Source
var ErrBufTooSmall = errors.New("buffer too small")
View Source
var ErrOverflow = errors.New("varint overflows a 64-bit integer")
View Source
var ErrReuseBufTooSmall = errors.New("reuse buffer too small")
View Source
var ErrVerifyMarshal = errors.New("check for a mistake in calculating the size or in the marshal process")
View Source
var ErrVerifyUnmarshal = errors.New("check for a mistake in the unmarshal process")

Functions

func VerifyMarshal

func VerifyMarshal(n int, b []byte) error

Verifies that the length of the buffer equals n

func VerifyUnmarshal

func VerifyUnmarshal(n int, b []byte) error

Verifies that the length of the buffer equals n

func WithBufferSize added in v1.0.9

func WithBufferSize(bufSize uint) optFunc

Types

type BufPool added in v1.0.9

type BufPool struct {
	BufSize uint
	// contains filtered or unexported fields
}

func NewBufPool added in v1.0.9

func NewBufPool(opts ...optFunc) *BufPool

func (*BufPool) Marshal added in v1.0.9

func (bp *BufPool) Marshal(s int, f func(b []byte) (n int)) ([]byte, error)

Initialises the marshal process, it reuses the buffers from a buf pool instance

s = size of the data in bytes, retrieved by using the benc `Size...` methods

type Opts added in v1.0.9

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

Directories

Path Synopsis
cmd
impl
gen

Jump to

Keyboard shortcuts

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