authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-08-04 02:24:33 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-08-04 02:24:33 -07:00
log849860a0e6c3029353d476decb8d220bb7cc5389
tree47cddcec7043e561a35101bd2c3dd1936d4e1180
parente56b9fed6c0afd1c4d29bedc08c3899ffe1165e9

upstreaming local changes


1 files changed, 7 insertions(+), 4 deletions(-)

yaml.zig+7-4
...@@ -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 }
116115
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 }
120119
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 }
136135
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;