mirror of
https://github.com/luxfi/lattice.git
synced 2026-09-24 00:25:44 +00:00
[buffer]: added wrapper with int64 counter
This commit is contained in:
@@ -8,6 +8,17 @@ import (
|
||||
"github.com/tuneinsight/lattigo/v4/utils"
|
||||
)
|
||||
|
||||
// Read reads a slice of bytes from r and copies it on c.
|
||||
func Read(r Reader, c []byte) (n int64, err error){
|
||||
slice, err := r.Peek(len(c))
|
||||
if err != nil {
|
||||
return int64(len(slice)), err
|
||||
}
|
||||
copy(c, slice)
|
||||
nint, err := r.Discard(len(c))
|
||||
return int64(nint), err
|
||||
}
|
||||
|
||||
// ReadInt reads an int values from r and stores the result into *c.
|
||||
func ReadInt(r Reader, c *int) (n int64, err error) {
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Write writes a slice of bytes to w.
|
||||
func Write(w Writer, c []byte) (n int64, err error){
|
||||
nint, err := w.Write(c)
|
||||
return int64(nint), err
|
||||
}
|
||||
|
||||
// WriteInt writes an int c to w.
|
||||
func WriteInt(w Writer, c int) (n int64, err error) {
|
||||
nint, err := WriteUint64(w, uint64(c))
|
||||
|
||||
Reference in New Issue
Block a user