Skip to content

Commit

Permalink
add util to read one byte (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
dshulyak authored Jan 10, 2023
1 parent 36500a7 commit accac0d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ func (d *Decoder) read(buf []byte) (int, error) {
return io.ReadFull(d.r, buf)
}

func DecodeByte(d *Decoder) (byte, int, error) {
n, err := d.read(d.scratch[:1])
if err != nil {
return 0, n, err
}
return d.scratch[0], n, err
}

func DecodeCompact8(d *Decoder) (uint8, int, error) {
var (
value uint8
Expand Down

0 comments on commit accac0d

Please sign in to comment.