refactor: improve type safety of Buffer.Ref values in messages

This commit is contained in:
CJ van den Berg 2026-01-22 15:12:57 +01:00
parent 0abfabc365
commit 6d86807e21
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 6 additions and 4 deletions

View file

@ -1760,12 +1760,12 @@ pub const Ref = enum(usize) {
pub fn cborEncode(self: @This(), writer: *std.Io.Writer) std.io.Writer.Error!void {
const value: usize = @intFromEnum(self);
try cbor.writeValue(writer, value);
try cbor.writeValue(writer, .{ "BREF", value });
}
pub fn cborExtract(self: *@This(), iter: *[]const u8) cbor.Error!bool {
var value: usize = 0;
if (try cbor.matchValue(iter, cbor.extract(&value))) {
if (try cbor.matchValue(iter, .{ "BREF", cbor.extract(&value) })) {
self.* = @enumFromInt(value);
return true;
}