lib/handsum: add EncodeOptions type

This commit is contained in:
Nigel Tao committed 2025-03-02 14:10:11 +11:00
1 parent 6e91caf241
commit 263bbfabf0
2 files changed
+12 -3

No files matched your search

+2 -2
View File
@@ -105,7 +105,7 @@ func encode(inFile *os.File) error {
if err != nil { if err != nil {
return err return err
} }
return handsum.Encode(os.Stdout, src) return handsum.Encode(os.Stdout, src, nil)
} }
func roundtrip(inFile *os.File) error { func roundtrip(inFile *os.File) error {
@@ -114,7 +114,7 @@ func roundtrip(inFile *os.File) error {
return err return err
} }
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
err = handsum.Encode(buf, src) err = handsum.Encode(buf, src, nil)
if err != nil { if err != nil {
return err return err
} }
+10 -1
View File
@@ -64,8 +64,17 @@ var (
ErrUnsupportedFileVersion = errors.New("handsum: unsupported file version") ErrUnsupportedFileVersion = errors.New("handsum: unsupported file version")
) )
// EncodeOptions are optional arguments to Encode. The zero value is valid and
// means to use the default configuration.
//
// There are no fields for now, but there may be some in the future.
type EncodeOptions struct {
}
// Encode writes src to w in the Handsum format. // Encode writes src to w in the Handsum format.
func Encode(w io.Writer, src image.Image) error { //
// options may be nil, which means to use the default configuration.
func Encode(w io.Writer, src image.Image, options *EncodeOptions) error {
if (w == nil) || (src == nil) { if (w == nil) || (src == nil) {
return ErrBadArgument return ErrBadArgument
} }