-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve byte string format decoding options #550
Improve byte string format decoding options #550
Conversation
While at it, also improve docs.
@x448 PTAL 🙏 |
@benluddy PTAL 🙏 |
// ByteSliceExpectedEncodingMode specifies how to decode a byte string NOT enclosed in an "expected | ||
// later encoding" tag (RFC 8949 Section 3.4.5.2) into a Go byte slice. | ||
type ByteSliceExpectedEncodingMode int | ||
// ByteStringExpectedFormatMode specifies how to decode CBOR byte string into Go byte slice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. The old suffix "EncodingMode" for a decoding mode name would have been confusing.
@@ -1503,13 +1503,13 @@ func TestEncodeBuiltinTag(t *testing.T) { | |||
{ | |||
name: "unsigned bignum content not enclosed in expected encoding tag", | |||
tag: Tag{Number: tagNumUnsignedBignum, Content: []byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, | |||
opts: EncOptions{ByteSlice: ByteSliceExpectedEncodingBase16}, | |||
opts: EncOptions{ByteSlice: ByteSliceToByteStringWithExpectedConversionToBase16}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't named in this PR but ByteSliceToByteStringWithExpectedConversionToBase16
can be renamed to a shorter name.
This PR improves unreleased decoding options to be included in v2.7.0.
Changes include:
Renamed
ByteSliceExpectedEncodingMode
toByteStringExpectedFormatMode
, also renamed related optionsRenamed
DecOptions.ByteSliceExpectedEncoding
toDecOptions.ByteStringExpectedFormat
Added
ByteStringExpectedFormatError
, which is returned when decoding expected format failsUpdated comments to improve docs. For example,