pickle

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotPickle = errors.New("cannot pickle")

A Pickler can return ErrCannotPickle to indicate that it does not support pickling a particular value.

Functions

This section is empty.

Types

type Decoder

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

A Decoder decodes pickled values from an underlying Reader.

func NewDecoder

func NewDecoder(r io.Reader, unpickler Unpickler) *Decoder

NewDecoder creates a new Decoder that reads from the given reader and unpickles non-primitive values using the given Unpickler.

func (*Decoder) Decode

func (d *Decoder) Decode() (x starlark.Value, err error)

Decode decodes the next value from the underlying Reader.

type Encoder

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

An Encoder encodes values to an underlying Writer.

func NewEncoder

func NewEncoder(w io.Writer, pickler Pickler) *Encoder

NewEncoder creates a new Encoder that writes to the given reader and pickles non-primitive values using the given Pickler.

func (*Encoder) Encode

func (e *Encoder) Encode(x starlark.Value) (err error)

Encode encodes the given value to the underlying Writer.

type Pickler

type Pickler interface {
	// Pickle is called to pickle a non-primitive value.
	Pickle(x starlark.Value) (module, name string, args starlark.Tuple, err error)
}

Pickler may be implemented to provide support for pickling non-primitive values.

type PicklerFunc

type PicklerFunc func(x starlark.Value) (module, name string, args starlark.Tuple, err error)

A PicklerFunc is an implementation of Pickler that implements Pickle by calling itself.

func (PicklerFunc) Pickle

func (f PicklerFunc) Pickle(x starlark.Value) (module, name string, args starlark.Tuple, err error)

type Unpickler

type Unpickler interface {
	// Unpickle is called to unpickle a non-primitive value.
	Unpickle(module, name string, args starlark.Tuple) (starlark.Value, error)
}

Unpickler may be implemented to provide support for unpickling non-primitive values.

type UnpicklerFunc

type UnpicklerFunc func(module, name string, args starlark.Tuple) (starlark.Value, error)

An UnpicklerFunc is an implementation of Unpickler that implements Unpickle by calling itself.

func (UnpicklerFunc) Unpickle

func (f UnpicklerFunc) Unpickle(module, name string, args starlark.Tuple) (starlark.Value, error)

Jump to

Keyboard shortcuts

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