github.com/consensys/gnark@v0.11.0/io/io.go (about) 1 /* 2 Copyright © 2020 ConsenSys 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // Package io offers serialization interfaces for gnark objects. 18 package io 19 20 import ( 21 "io" 22 ) 23 24 // WriterRawTo is the interface that wraps the WriteRawTo method. 25 // 26 // WriteRawTo writes data to w until there's no more data to write or 27 // when an error occurs. The return value n is the number of bytes 28 // written. Any error encountered during the write is also returned. 29 // 30 // WriteRawTo will not compress the data (as opposed to WriteTo) 31 type WriterRawTo interface { 32 WriteRawTo(w io.Writer) (n int64, err error) 33 } 34 35 // UnsafeReaderFrom is the interface that wraps the UnsafeReadFrom method. 36 // 37 // UnsafeReadFrom reads data from reader but doesn't perform any checks, such as 38 // subgroup checks for elliptic curves points for example. 39 type UnsafeReaderFrom interface { 40 UnsafeReadFrom(r io.Reader) (int64, error) 41 } 42 43 // BinaryDumper is the interface that wraps the WriteDump and ReadDump methods. 44 // WriteDump writes the object to w, ReadDump reads the object from r. 45 // The object is serialized in binary format, in a very fast, very unsafe way. 46 type BinaryDumper interface { 47 WriteDump(w io.Writer) error 48 ReadDump(r io.Reader) error 49 }