fix: more zig-0.15 api fixes

This commit is contained in:
CJ van den Berg 2025-09-25 15:12:35 +02:00
parent 0b72daf165
commit 9361399898
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -183,9 +183,11 @@ pub const message = struct {
return fmtbuf_internal(buf, .{value}); return fmtbuf_internal(buf, .{value});
} }
fn fmtbuf_internal(buf: []u8, value: anytype) !Self { fn fmtbuf_internal(buf: []u8, value: anytype) error{NoSpaceLeft}!Self {
var stream: std.Io.Writer = .fixed(buf); var stream: std.Io.Writer = .fixed(buf);
try cbor.writeValue(&stream, value); cbor.writeValue(&stream, value) catch |e| return switch (e) {
error.WriteFailed => error.NoSpaceLeft,
};
return .{ .buf = stream.buffered() }; return .{ .buf = stream.buffered() };
} }
@ -221,7 +223,7 @@ pub const message = struct {
} }
pub fn format(self: @This(), writer: anytype) std.Io.Writer.Error!void { pub fn format(self: @This(), writer: anytype) std.Io.Writer.Error!void {
return cbor.toJsonWriter(self.buf, writer, .{}); return cbor.toJsonWriter(self.buf, writer, .{}) catch error.WriteFailed;
} }
}; };