Skip to content

Commit

Permalink
meta data updated
Browse files Browse the repository at this point in the history
  • Loading branch information
r4gus committed May 20, 2024
1 parent df76bb2 commit 6fa20a0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ authors:
orcid: "https://orcid.org/0009-0007-0056-602X"
repository-code: 'https://github.com/r4gus/zbor'
abstract: 'CBOR parser written in Zig'
version: 0.13.0
date-released: 2024-04-20
version: 0.14.0
date-released: 2024-05-20
keywords:
- cbor
- rfc8949
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,28 @@ pub fn cborStringify(self: *const @This(), options: cbor.StringifyOptions, out:

When using `parse` make sure you pass a allocator to the function. The passed allocator will be assigned
to the field of type `std.mem.Allocator`.

### ArrayBackedSlice

This library offers a convenient function named ArrayBackedSlice, which enables you to create a wrapper for an array of any size and type. This wrapper implements the cborStringify and cborParse methods, allowing it to seamlessly replace slices (e.g., []const u8) with an array.

```zig
test "ArrayBackedSlice test" {
const allocator = std.testing.allocator;
const S64B = ArrayBackedSlice(64, u8, .Byte);
var x = S64B{};
try x.set("\x01\x02\x03\x04");
var str = std.ArrayList(u8).init(allocator);
defer str.deinit();
try stringify(x, .{}, str.writer());
try std.testing.expectEqualSlices(u8, "\x44\x01\x02\x03\x04", str.items);
const di = try DataItem.new(str.items);
const y = try parse(S64B, di, .{});
try std.testing.expectEqualSlices(u8, "\x01\x02\x03\x04", y.get());
}
```
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = "zbor",
// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.13.0",
.version = "0.14.0",

// This field is optional.
// This is currently advisory only; Zig does not yet do anything
Expand Down
2 changes: 1 addition & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub const ArrayBackedSlice = parser.ArrayBackedSlice;
pub const ArrayBackedSliceType = parser.ArrayBackedSliceType;

// TODO: can we somehow read this from build.zig.zon???
pub const VERSION: []const u8 = "0.13.0";
pub const VERSION: []const u8 = "0.14.0";

test "main tests" {
_ = cbor;
Expand Down

0 comments on commit 6fa20a0

Please sign in to comment.