Skip to content

Commit

Permalink
Add PeekDiscriminator
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Oct 30, 2022
1 parent 757b109 commit f81f528
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 @@ -349,6 +349,14 @@ func (dec *Decoder) ReadDiscriminator() (out TypeID, err error) {
return dec.ReadTypeID()
}

func (dec *Decoder) PeekDiscriminator() (out TypeID, err error) {
discriminator, err := dec.Peek(8)
if err != nil {
return TypeID{}, err
}
return TypeIDFromBytes(discriminator), nil
}

func (dec *Decoder) Peek(n int) (out []byte, err error) {
if n < 0 {
err = fmt.Errorf("n not valid: %d", n)
Expand Down

0 comments on commit f81f528

Please sign in to comment.