╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │15 description: []const u8, │ │16 tags: []const u8, │ │17 }, │ │18 + │ │19 + pub fn read( │ │20 + comptime DB: type, │ │21 + comptime hash_kind: hash.HashKind, │ │22 + allocator: std.mem.Allocator, │ │23 + map: DB.HashMap(.read_only), │ │24 + kind: EventKind, │ │25 + ) !EventData { │ │26 + return switch (kind) { │ │27 + .issue => .{ │ │28 + .issue = .{ │ │29 + .title = try readBytes(DB, hash_kind, allocator, map, "title"), │ │30 + .description = try readBytes(DB, hash_kind, allocator, map, "description"), │ │31 + .tags = try readBytes(DB, hash_kind, allocator, map, "tags"), │ │32 + }, │ │33 + }, │ │34 + }; │ │35 + } │ │36 + │ │37 + fn readBytes( │ │38 + comptime DB: type, │ │39 + comptime hash_kind: hash.HashKind, │ │40 + allocator: std.mem.Allocator, │ │41 + map: DB.HashMap(.read_only), │ │42 + field_name: []const u8, │ │43 + ) ![]const u8 { │ │44 + const cursor = try map.getCursor(hash.hashInt(hash_kind, field_name)) orelse return error.NotFound;│ │45 + return try cursor.readBytesAlloc(allocator, null); │ │46 + } │ │47 }; │ │48 │ │49 pub const Event = struct { │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │156 try history.appendContext(.{ .slot = try history.getSlot(-1) }, Ctx{ .repo_events = repo_events });│ │157 } │ │158 │ │130 -pub fn read( │ │131 - comptime DB: type, │ │132 - comptime hash_kind: hash.HashKind, │ │133 - allocator: std.mem.Allocator, │ │134 - map: DB.HashMap(.read_only), │ │135 - kind: EventKind, │ │136 -) !EventData { │ │137 - return switch (kind) { │ │138 - .issue => .{ │ │139 - .issue = .{ │ │140 - .title = try readBytes(DB, hash_kind, allocator, map, "title"), │ │141 - .description = try readBytes(DB, hash_kind, allocator, map, "description"), │ │142 - .tags = try readBytes(DB, hash_kind, allocator, map, "tags"), │ │143 - }, │ │144 - }, │ │145 - }; │ │146 -} │ │147 - │ │148 -fn readBytes( │ │149 - comptime DB: type, │ │150 - comptime hash_kind: hash.HashKind, │ │151 - allocator: std.mem.Allocator, │ │152 - map: DB.HashMap(.read_only), │ │153 - field_name: []const u8, │ │154 -) ![]const u8 { │ │155 - const cursor = try map.getCursor(hash.hashInt(hash_kind, field_name)) orelse return error.NotFound;│ │156 - return try cursor.readBytesAlloc(allocator, null); │ │157 -} │ │158 - │ │159 fn upsert( │ │160 comptime DB: type, │ │161 comptime hash_kind: hash.HashKind, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯