No description
Find a file
2025-11-06 18:49:11 -03:00
.github/workflows CI use main branch for tests (#14) 2025-10-28 17:45:07 -03:00
cbor_serialization write/read tuple as array (#11) 2025-10-27 17:28:35 -03:00
docs Fix docs examples (#15) 2025-10-28 22:56:51 -03:00
tests Run all tests at comptime (#16) 2025-11-06 18:49:11 -03:00
.gitignore CI: use nimble head (#3) 2025-10-27 17:28:35 -03:00
cbor_serialization.nim Initial (#1) 2025-10-27 17:28:35 -03:00
cbor_serialization.nimble Run all tests at comptime (#16) 2025-11-06 18:49:11 -03:00
config.nims Initial (#1) 2025-10-27 17:28:35 -03:00
LICENSE-APACHEv2 Initial (#1) 2025-10-27 17:28:35 -03:00
LICENSE-MIT Initial (#1) 2025-10-27 17:28:35 -03:00
README.md Small refactor (#7) 2025-10-27 17:28:35 -03:00

nim-cbor-serialization

License: Apache License: MIT Stability: experimental Github action

Introduction

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 CborValueRef node type for DOM-style access to parsed data
    • Flat CborBytes type for passing nested CBOR data between abstraction layers
  • 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

Getting started

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.cborrpc

Documentation

See the user guide.

Contributing

Contributions are welcome - please make sure to add test coverage for features and fixes!

cbor_serialization follows the Status Nim Style Guide.

License

Licensed and distributed under either of

or

at your option. These files may not be copied, modified, or distributed except according to those terms.