@@ -255,7 +255,7 @@ pub fn FieldUpdater(comptime Obj: type, comptime optional_fields: []const std.me
255
255
256
256
pub fn set (fup : * FUP , comptime field : FieldName , value : @FieldType (Obj , @tagName (field ))) ! void {
257
257
if (fup .updated_fields .contains (field )) {
258
- fup .ctx .report_nonfatal_error ("duplicate assignment of {s}.{s}" , .{
258
+ try fup .ctx .report_nonfatal_error ("duplicate assignment of {s}.{s}" , .{
259
259
@typeName (Obj ),
260
260
@tagName (field ),
261
261
});
@@ -273,7 +273,7 @@ pub fn FieldUpdater(comptime Obj: type, comptime optional_fields: []const std.me
273
273
missing_fields = missing_fields .complement ();
274
274
var iter = missing_fields .iterator ();
275
275
while (iter .next ()) | fld | {
276
- fup .ctx .report_nonfatal_error ("missing assignment of {s}.{s}" , .{
276
+ try fup .ctx .report_nonfatal_error ("missing assignment of {s}.{s}" , .{
277
277
@typeName (Obj ),
278
278
@tagName (fld ),
279
279
});
@@ -290,6 +290,8 @@ const Environment = struct {
290
290
UnknownContentType ,
291
291
FatalConfigError ,
292
292
InvalidEnumTag ,
293
+ Overflow ,
294
+ InvalidSize ,
293
295
};
294
296
295
297
arena : std.mem.Allocator ,
@@ -341,6 +343,24 @@ pub const Content = struct {
341
343
obj : * anyopaque ,
342
344
vtable : * const VTable ,
343
345
346
+ pub const empty : Content = .{
347
+ .obj = undefined ,
348
+ .vtable = & emptyVTable ,
349
+ };
350
+
351
+ const emptyVTable : VTable = blk : {
352
+ const Wrap = struct {
353
+ fn render (_ : * anyopaque , _ : * BinaryStream ) RenderError ! void {}
354
+ fn guess_size_fn (_ : * anyopaque ) GuessError ! SizeGuess {
355
+ return .{ .exact = 0 };
356
+ }
357
+ };
358
+ break :blk .{
359
+ .render_fn = Wrap .render ,
360
+ .guess_size_fn = Wrap .guess_size_fn ,
361
+ };
362
+ };
363
+
344
364
pub fn create_handle (obj : * anyopaque , vtable : * const VTable ) Content {
345
365
return .{ .obj = obj , .vtable = vtable };
346
366
}
@@ -361,10 +381,13 @@ pub const Content = struct {
361
381
render_fn : * const fn (* anyopaque , * BinaryStream ) RenderError ! void ,
362
382
guess_size_fn : * const fn (* anyopaque ) GuessError ! SizeGuess ,
363
383
364
- pub fn create (comptime Container : type , comptime funcs : struct {
365
- render_fn : * const fn (* Container , * BinaryStream ) RenderError ! void ,
366
- guess_size_fn : * const fn (* Container ) GuessError ! SizeGuess ,
367
- }) * const VTable {
384
+ pub fn create (
385
+ comptime Container : type ,
386
+ comptime funcs : struct {
387
+ render_fn : * const fn (* Container , * BinaryStream ) RenderError ! void ,
388
+ guess_size_fn : * const fn (* Container ) GuessError ! SizeGuess ,
389
+ },
390
+ ) * const VTable {
368
391
const Wrap = struct {
369
392
fn render (self : * anyopaque , stream : * BinaryStream ) RenderError ! void {
370
393
return funcs .render_fn (
0 commit comments