| ... | @@ -33,8 +33,7 @@ pub const Item = union(enum) { | ... | @@ -33,8 +33,7 @@ pub const Item = union(enum) { |
| 33 | try writer.writeAll("Item{"); | 33 | try writer.writeAll("Item{"); |
| 34 | switch (self) { | 34 | switch (self) { |
| 35 | .event => { | 35 | .event => { |
| 36 | // try std.fmt.format(writer, "{s}", .{@tagName(self.event.type)}); | 36 | try std.fmt.format(writer, "event {}", .{self.event}); |
| 37 | try std.fmt.format(writer, "event {d}", .{self.event}); | | |
| 38 | }, | 37 | }, |
| 39 | .kv, .document, .stream => { | 38 | .kv, .document, .stream => { |
| 40 | unreachable; | 39 | unreachable; |
| ... | @@ -114,8 +113,8 @@ pub const Mapping = struct { | ... | @@ -114,8 +113,8 @@ pub const Mapping = struct { |
| 114 | return null; | 113 | return null; |
| 115 | } | 114 | } |
| 116 | | 115 | |
| 117 | pub fn get_string(self: Mapping, k: string) string { | 116 | pub fn get_string(self: Mapping, k: string) ?string { |
| 118 | return if (self.get(k)) |v| v.string else ""; | 117 | return self.getT(k, .string); |
| 119 | } | 118 | } |
| 120 | | 119 | |
| 121 | pub fn get_string_array(self: Mapping, alloc: std.mem.Allocator, k: string) ![]string { | 120 | pub fn get_string_array(self: Mapping, alloc: std.mem.Allocator, k: string) ![]string { |
| ... | @@ -134,6 +133,10 @@ pub const Mapping = struct { | ... | @@ -134,6 +133,10 @@ pub const Mapping = struct { |
| 134 | return list.toOwnedSlice(); | 133 | return list.toOwnedSlice(); |
| 135 | } | 134 | } |
| 136 | | 135 | |
| | 136 | pub fn getMap(self: Mapping, k: string) ?Mapping { |
| | 137 | return self.getT(k, .mapping); |
| | 138 | } |
| | 139 | |
| 137 | pub fn format(self: Mapping, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void { | 140 | pub fn format(self: Mapping, comptime fmt: string, options: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void { |
| 138 | _ = fmt; | 141 | _ = fmt; |
| 139 | _ = options; | 142 | _ = options; |