Releases: ldclabs/cbor2
v1.0.5
feat: support flattened CBOR extension maps Add #[serde(flatten)] support for map-shaped #[derive(Cbor)] structs and preserve integer COSE labels through CBOR round trips. Add cbor encode --hex and cbor validate for agent-friendly CLI workflows. Bump cbor2 crates to 1.0.5 and switch project metadata and docs to MIT-only licensing. Co-Authored-By: Anda Bot <noreply@anda.bot>
v1.0.4
feat: allow transparent CBOR tag decoding Co-Authored-By: Anda Bot <noreply@anda.bot>
v1.0.3
perf: add benchmarks and optimize encoding Add a detached cbor2-bench workspace with comparative CBOR benchmark fixtures, result tables, and README documentation. Optimize hot encode and slice decode paths while appending the results to the 1.0.3 changelog. Co-Authored-By: Anda Bot <noreply@anda.bot>
v1.0.2
ci: add crates publish workflow Add a tag-triggered crates.io publishing workflow, update GitHub Actions checkout steps to v5, and track the workspace Cargo.lock for reproducible CI and release automation. Co-Authored-By: Anda Bot <noreply@anda.bot>
v1.0.0
The first stable release, completing the rewrite that shipped as 0.5.0.
Added
-
no_stdsupport behind the newstd(default) andallocfeatures.
default-features = false, features = ["alloc"]keeps the full API
minus thestd::ioblanket implementations and theHashMap
conversions; readers and writers are byte slices,Vec<u8>, or custom
cbor2::iotrait implementations. Withoutallocthe crate is a
serialization/validation core:to_writer/to_slice/serialized_size,
validate, thetagwrappers and thecoreheader codec (the serde
deserializer needs a heap; error messages composed at runtime are
reduced to static ones). -
to_slice: encodes into a caller-provided buffer and returns the
written prefix, without allocating. Available in every configuration. -
A
RawValuetype holding one item as validated, undecoded bytes (in
the spirit ofserde_json::value::RawValue): serialization splices
the bytes into the stream untouched and deserialization captures them
byte for byte — exact even for non-preferred spellings — for
signature payloads, pass-through items and deferred decoding.
TryFromconverts in both directions betweenRawValueandValue
(decoding and encoding respectively). -
CBOR tags on containers:
#[cbor(tag = 18)]wraps a struct in a tag
(required on decode), alongside the integer map keys of 0.5.0. -
Valueconversions to and from the common std types:Fromcovers
the primitive scalars,Option, byte arrays/vectors,
String/&str/Cow<str>,HashMap/BTreeMap(anyInto<Value>
keys and values) andFromIteratorinto an array;TryFrom<Value>
extracts every variant's payload, range-checked integers (the 128-bit
forms accept bignums) and typedHashMap/BTreeMapwith serde-style
error messages. -
A
cbor2::Cbortrait implemented by#[derive(Cbor)](sharing its
name with the derive macro, serde-style), exposing the declared
protocol details at runtime:T::KEYS(thefield name → integer key
pairs) andT::TAGas allocation-free constants, plus a
keys(&self) -> BTreeMap<String, i128>convenience method with
alloc. -
The tools package, renamed from
cbor_convtocbor2-cli(published
for the first time, also as 1.0.0), now ships a singlecborcommand
line tool. Barecborshows each CBOR item as one line of diagnostic
notation (RFC 8949 §8) with full wire fidelity — indefinite-length
markers,undefined, bignums as plain integers;cbor decode
pretty-prints items as JSON or, with--diag, as indented diagnostic
notation;cbor encodeconverts JSON values to CBOR (replacing the
oldjson2cbor/cbor2jsonbinaries). The CBOR-reading commands take
their input from stdin, a file, a hex string or a base64/base64url
string, and everything is covered by end-to-end tests.
Changed
- The serde
Serializer/Deserializernow run over thecbor2::io
reader/writer traits. With the defaultstdfeature these are
implemented for everystd::io::Write/Readandcbor2::io::Error
isstd::io::Error, so existing code is unaffected. - The
derivefeature's#[cbor2::int_keys]attribute macro is
replaced by#[derive(cbor2::Cbor)], which generates the serde
Serialize/Deserializeimpls itself (serde's derives must not be
repeated alongside it). Field names and the type name stay untouched —
the protocol details ride on a hidden serde-remoteshadow type — so
the same types serialize to plain JSON with the original field names
and no tag:serde_json::to_string(&v)just works. - Error types implement the error trait through
serde::ser::StdError,
which isstd::error::Errorwheneverstdis available.