frob

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package frob is a fast restricted object encoder/decoder in the spirit of encoding/gob.

As with gob, types that recursively contain functions, channels, and unsafe.Pointers cannot be encoded, but frob has these additional restrictions:

  • Interface values are not supported; this avoids the need for the encoding to describe types.

  • Types that recursively contain private struct fields are not permitted.

  • The encoding is unspecified and subject to change, so the encoder and decoder must exactly agree on their implementation and on the definitions of the target types.

  • Lengths (of arrays, slices, and maps) are currently assumed to fit in 32 bits.

  • There is no error handling. All errors are reported by panicking.

  • Values are serialized as trees, not graphs, so shared subgraphs are encoded repeatedly.

  • No attempt is made to detect cyclic data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec[T any] struct {
	// contains filtered or unexported fields
}

A Codec[T] is an immutable encoder and decoder for values of type T.

func CodecFor

func CodecFor[T any]() Codec[T]

CodecFor[T] returns a codec for values of type T. It panics if type T is unsuitable.

func (Codec[T]) Decode

func (codec Codec[T]) Decode(data []byte, ptr *T)

func (Codec[T]) Encode

func (codec Codec[T]) Encode(v T) []byte

Jump to

Keyboard shortcuts

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