jldb/mdb/change/binary.go

27 lines
493 B
Go
Raw Permalink Normal View History

2023-10-13 09:43:27 +00:00
package change
import (
"encoding/binary"
"io"
2023-10-16 08:50:19 +00:00
2023-10-13 09:43:27 +00:00
"git.crumpington.com/public/jldb/lib/errs"
)
func writeBin(w io.Writer, data ...any) error {
for _, value := range data {
if err := binary.Write(w, binary.LittleEndian, value); err != nil {
return errs.IO.WithErr(err)
}
}
return nil
}
func readBin(r io.Reader, ptrs ...any) error {
for _, ptr := range ptrs {
if err := binary.Read(r, binary.LittleEndian, ptr); err != nil {
return errs.IO.WithErr(err)
}
}
return nil
}