serialize

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBinaryFile

func IsBinaryFile(path string) bool

func LoadSerializedBinary

func LoadSerializedBinary[X any](inputPath string) (*X, error)

func Write

func Write[X Serializable](outputPath string, x X, perm os.FileMode) error

func WriteSerializedBinary

func WriteSerializedBinary(value Serializable, target ioutil.OutputTarget) error

Types

type BinaryReader

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

BinaryReader provides methods to decode content written by BinaryWriter.

func NewBinaryReader

func NewBinaryReader(in io.Reader) *BinaryReader

func (*BinaryReader) ReadBool

func (r *BinaryReader) ReadBool(target *bool) error

func (*BinaryReader) ReadBytes

func (r *BinaryReader) ReadBytes(target *[]byte) error

func (*BinaryReader) ReadHash

func (r *BinaryReader) ReadHash(target *common.Hash) error

func (*BinaryReader) ReadUInt

func (r *BinaryReader) ReadUInt(target any) error

type BinaryWriter

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

BinaryWriter writes a simple binary format which can be read again using BinaryReader. The format is a simple concatenation of values, with prefixed length for variable length items. All numbers are encoded using big endian.

func NewBinaryWriter

func NewBinaryWriter(out io.Writer) *BinaryWriter

func (*BinaryWriter) WriteBool

func (w *BinaryWriter) WriteBool(v bool) error

func (*BinaryWriter) WriteBytes

func (w *BinaryWriter) WriteBytes(v []byte) error

func (*BinaryWriter) WriteHash

func (w *BinaryWriter) WriteHash(v common.Hash) error

func (*BinaryWriter) WriteUInt

func (w *BinaryWriter) WriteUInt(v any) error

type Deserializable

type Deserializable interface {
	// Deserialize decodes raw bytes into the type.
	Deserialize(in io.Reader) error
}

Deserializable defines functionality for a type that may be deserialized from raw bytes.

type Serializable

type Serializable interface {
	// Serialize encodes the type as raw bytes.
	Serialize(out io.Writer) error
}

Serializable defines functionality for a type that may be serialized to raw bytes.

Jump to

Keyboard shortcuts

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