io

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package io offers serialization interfaces for gnark objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpRoundTripCheck

func DumpRoundTripCheck(from any, to func() any) error

func RoundTripCheck

func RoundTripCheck(from any, to func() any) error

RoundTripCheck is a helper to check that a serialization round trip is correct. It writes the object to a buffer, then reads it back and checks that the reconstructed object is equal to the original. It supports both io.ReaderFrom and UnsafeReaderFrom interfaces (to object) It also supports both io.WriterTo and WriterRawTo interfaces (from object)

Types

type BinaryDumper

type BinaryDumper interface {
	WriteDump(w io.Writer) error
	ReadDump(r io.Reader) error
}

BinaryDumper is the interface that wraps the WriteDump and ReadDump methods. WriteDump writes the object to w, ReadDump reads the object from r. The object is serialized in binary format, in a very fast, very unsafe way.

type UnsafeReaderFrom

type UnsafeReaderFrom interface {
	UnsafeReadFrom(r io.Reader) (int64, error)
}

UnsafeReaderFrom is the interface that wraps the UnsafeReadFrom method.

UnsafeReadFrom reads data from reader but doesn't perform any checks, such as subgroup checks for elliptic curves points for example.

type WriterRawTo

type WriterRawTo interface {
	WriteRawTo(w io.Writer) (n int64, err error)
}

WriterRawTo is the interface that wraps the WriteRawTo method.

WriteRawTo writes data to w until there's no more data to write or when an error occurs. The return value n is the number of bytes written. Any error encountered during the write is also returned.

WriteRawTo will not compress the data (as opposed to WriteTo)

Jump to

Keyboard shortcuts

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