-
Release v1.1.0 Stable
released this
2026-03-12 21:14:52 +00:00 | 6 commits to master since this releaseFeatures
- Custom encoder hooks: Types can implement
cborEncode(writer: *Io.Writer) !void
to control their own serialisation. - Custom extractor hooks: Types can implement
cborExtract(iter: *[]const u8) !bool
to 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 a
matchpattern.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 handles
json.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 than
i64were encoded incorrectly due to signed overflow.matchStructScalar/matchStructAlloc: A short read returned
falseinstead 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.
Downloads
-
Source code (ZIP)
0 downloads
-
Source code (TAR.GZ)
0 downloads
- Custom encoder hooks: Types can implement