nim-cbor-serialization is a library in the nim-serialization family for turning Nim objects into CBOR and back. Features include:
- Efficient coding of CBOR directly to and from Nim data types
- Full type-based customization of both encoding and decoding
- Flavors for defining multiple CBOR serialization styles per Nim type
- Efficient skipping of data items for partial CBOR parsing
- Flexibility in mixing type-based and dynamic CBOR access
- Structured
CborValueRefnode type for DOM-style access to parsed data - Flat
CborBytestype for passing nested CBOR data between abstraction layers
- Structured
- RFC8949 spec compliance
- Passes CBORTestVectors
- Customizable parser strictness including support for non-standard extensions
- Well-defined handling of malformed / malicious inputs with configurable parsing limits
requires "cbor_serialization"Create a type and use it to encode and decode CBOR:
import cbor_serialization
type Request = object
cborrpc: string
`method`: string
let encoded = Cbor.encode(Request(cborrpc: "2.0", `method`: "name"))
let decoded = Cbor.decode(encoded, Request)
echo decoded.cborrpcSee the user guide.
Contributions are welcome - please make sure to add test coverage for features and fixes!
cbor_serialization follows the Status Nim Style Guide.
Licensed and distributed under either of
- MIT license: LICENSE-MIT or http://opensource.org/licenses/MIT
or
- Apache License, Version 2.0, (LICENSE-APACHEv2 or http://www.apache.org/licenses/LICENSE-2.0)
at your option. These files may not be copied, modified, or distributed except according to those terms.