╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1633 const bytes = try readBytes(DB, hash_kind, arena.allocator(), map, field.name); │ │1634 @field(event, field.name) = std.meta.stringToEnum(field.type, bytes) orelse return error.InvalidEnumTag; │ │1635 }, │ │1636 + .@"union" => { │ │1637 + if (!@hasDecl(field.type, "decode")) @compileError("unsupported read field type: " ++ @typeName(field.type)); │ │1638 + @field(event, field.name) = try field.type.decode(try readBytes(DB, hash_kind, arena.allocator(), map, field.name));│ │1639 + }, │ │1640 .optional => |optional_info| { │ │1641 // a missing key is null │ │1642 if (try map.getCursor(hash.hashInt(hash_kind, field.name))) |cursor| { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1713 @compileError("unsupported field type: " ++ @typeName(Field)); │ │1714 } │ │1715 }, │ │1716 + .void => return true, │ │1717 .bool, .int, .@"enum" => return a == b, │ │1718 + .@"union" => { │ │1719 + if (std.meta.activeTag(a) != std.meta.activeTag(b)) return false; │ │1720 + return switch (a) { │ │1721 + inline else => |value, tag| fieldEqual(@TypeOf(value), value, @field(b, @tagName(tag))),│ │1722 + }; │ │1723 + }, │ │1724 .@"struct" => return fieldsEqual(Field, a, b), │ │1725 .optional => |optional_info| { │ │1726 if (a) |a_value| { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────╮ │1861 try map.put(key, .{ .bytes_object = .{ .value = bytes, .format_tag = "bl".* } });│ │1862 }, │ │1863 .@"enum" => try upsertBytes(DB, hash_kind, map, key, @tagName(value)), │ │1864 + .@"union" => { │ │1865 + if (!@hasDecl(Field, "encode") or !@hasDecl(Field, "max_encoded_len")) { │ │1866 + @compileError("unsupported upsert field type: " ++ @typeName(Field)); │ │1867 + } │ │1868 + var buffer: [Field.max_encoded_len]u8 = undefined; │ │1869 + try upsertBytes(DB, hash_kind, map, key, try value.encode(&buffer)); │ │1870 + }, │ │1871 .optional => |optional_info| { │ │1872 // a missing key is null │ │1873 if (value) |child| { │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯