4.4 KiB
4.4 KiB
Release Notes — v1.2.0
2026-04-15
Breaking Changes
-
Zig 0.16.0 required: The minimum Zig version is now 0.16.0. Zig 0.15 is no longer supported.
-
extract(&obj)removed forjson.ObjectMap:std.json.ObjectMapbecame an unmanaged map in Zig 0.16 (allocator no longer stored internally), so the non-allocatingextract(&obj)overload cannot work. It has been removed; attempting to use it now produces a compile error. UseextractAlloc(&obj, allocator)instead:// before var obj = std.json.ObjectMap.init(allocator); defer obj.deinit(); _ = try cbor.match(buf, .{ cbor.extract(&obj) }); // after var obj: std.json.ObjectMap = .empty; defer obj.deinit(allocator); _ = try cbor.match(buf, .{ cbor.extractAlloc(&obj, allocator) });
Build
- Minimum Zig version is now 0.16.0.
- All internal APIs updated for Zig 0.16 compatibility (
std.Io, unmanagedjson.ObjectMap,std.Io.Writer, etc.).
Release Notes — v1.1.0
2026-03-12
Features
- Custom encoder hooks: Types can implement
cborEncode(writer: *Io.Writer) !voidto control their own serialisation. - Custom extractor hooks: Types can implement
cborExtract(iter: *[]const u8) !boolto control their own deserialisation. Enum types are now also supported viacborExtract. extractAlloc: New allocating extractor for types containing slices or heap-allocated payloads. UseextractAlloc(&dest, allocator)inside amatchpattern.extractAllocarrays:extractAllocnow handles[]Tslices, allocating and populating each element.- Struct and union extraction:
extractandextractAllocnow handle structs (decoded from CBOR maps) and tagged unions (decoded from two-element CBOR arrays of[tag, payload]). Enum extraction is also supported. fmtBuf: NewfmtBuf(buf, value) ![]const u8— likefmtbut returnserror.NoSpaceLeftinstead of panicking on overflow.fmtexplicit panic:fmtnow calls@panic("cbor.fmt: buffer too small")on overflow rather thancatch unreachable.- Non-u8 slice matching:
matchnow supports patterns of the form&[_]T{...}for slices and arrays where the element type is notu8. writeJsonValuearrays and objects:writeJsonValuenow handlesjson.Value.arrayandjson.Value.object.- More explicit error handling: Errors that were previously collapsed are now surfaced with distinct error values.
Bug Fixes
matchArraynon-match:matchArraywas incorrectly returning an error on a type mismatch instead offalse.decodeMapHeadererror type: Corrected the error return type to include all possible errors.- Missing
NotAnObjecterror: Added missing error variant to the error set. extractoptional null: Extracting a null CBOR value into a non-allocating optional now correctly sets the destination tonull.extractAllocoptional null: Same fix for the allocating extractor path.extractAllocjson.Valuearrays/objects: Fell through to union-match logic and failed. Now handled viamatchJsonValuewith the real allocator.decodeNIntoverflow: Decoding large negative integers (magnitude >maxInt(i64)) would panic. Now returnserror.IntegerTooSmall.skipValuetruncated floats: CallingskipValueon a truncated float16/32/64 would panic. Now returnserror.TooShort.matchJsonValuefloats: Float values were silently dropped during CBOR→json.Valueextraction. All three widths now decoded correctly.writeValuelarge unsigned integers: Unsigned integers wider thani64were encoded incorrectly due to signed overflow.matchStructScalar/matchStructAlloc: A short read returnedfalseinstead of propagatingerror.TooShort, masking corruption as a non-match.
Performance
writeTypedVal: Singlewriter.writecall instead of multiple single-byte writes.- Float encoding:
writeF16/writeF32/writeF64each issue a single write usingstd.mem.writeInt(also fixes a latent big-endian bug in the previous manual byte-swap code). decodeUIntLength: Replaced recursive implementation with an iterative one.fromJson/fromJsonAlloc: A single allocator is now threaded through the entire JSON parse instead of creating a new arena per nested container.
Build
- Minimum Zig version is now 0.15.2.
- Updated APIs for Zig 0.15 compatibility.