Skip to content

Commit

Permalink
Add ability to skip decoding in deserializer
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Aug 19, 2020
1 parent a126ec1 commit b2a1add
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ func (d *decoder) decodeToDeserializer(offset uint, dser deserializer, depth int
return 0, err
}

skip, err := dser.ShouldSkip(uintptr(offset))
if err != nil {
return 0, err
}
if skip {
return d.nextValueOffset(offset, 1)
}

return d.decodeFromTypeToDeserializer(typeNum, size, newOffset, dser, depth+1)
}

Expand Down
5 changes: 3 additions & 2 deletions deserializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import "math/big"
// It is not currently covered by any Semantic Versioning guarantees.
// Use at your own risk.
type deserializer interface {
StartSlice(uint) error
StartMap(uint) error
ShouldSkip(offset uintptr) (bool, error)
StartSlice(size uint) error
StartMap(size uint) error
End() error
String(string) error
Float64(float64) error
Expand Down

0 comments on commit b2a1add

Please sign in to comment.