-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for unassigned/reserved CBOR simple values (#370)
Add a SimpleValue type which is distinct from Go's numeric types. Add support for properly encoding and decoding all simple values, including 252 unassigned/reserved simple values. Improve support for simple values as map keys by making them distinct from uint64 values 0-255. CBOR simple values are a subset of major type 7 that is not floating-point. Only 4 simple values were previously supported by this codec: - false - true - null - undefined The other 252 simple values are unassigned or reserved by IANA.
- Loading branch information
Showing
5 changed files
with
116 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cbor | ||
|
||
import "reflect" | ||
|
||
// SimpleValue represents CBOR simple value. | ||
// CBOR simple value is: | ||
// * an extension point like CBOR tag. | ||
// * a subset of CBOR major type 7 that isn't floating-point. | ||
// * "identified by a number between 0 and 255, but distinct from that number itself". | ||
// For example, "a simple value 2 is not equivalent to an integer 2" as a CBOR map key. | ||
// CBOR simple values identified by 20..23 are: "false", "true" , "null", and "undefined". | ||
// Other CBOR simple values are currently unassigned/reserved by IANA. | ||
type SimpleValue uint8 | ||
|
||
var ( | ||
typeSimpleValue = reflect.TypeOf(SimpleValue(0)) | ||
) |