feat: add slightly more robust fmtBuf API

This commit is contained in:
CJ van den Berg 2026-03-12 21:42:13 +01:00
parent 0b1c94eae2
commit 46e7709232
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 20 additions and 0 deletions

View file

@ -301,6 +301,12 @@ pub fn fmt(buf: []u8, value: anytype) []const u8 {
return writer.buffered();
}
pub fn fmtBuf(buf: []u8, value: anytype) Io.Writer.Error![]const u8 {
var writer: Io.Writer = .fixed(buf);
try writeValue(&writer, value);
return writer.buffered();
}
const CborType = struct { type: u8, minor: u5, major: u3 };
pub fn decodeType(iter: *[]const u8) error{TooShort}!CborType {