╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Attachment.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
162 .blob = blob, 163 .event = .{ .attach = .{ .parent_id = parent_id.* } }, 164 }}); 165 return event_id; 166 } 167 168 // read an attachment by event id, or null if the id isn't a known attachment. 169 // field byte slices are allocated in `arena`. 170 pub fn readById( 171 comptime DB: type, 172 comptime hash_kind: hash.HashKind, 173 haxy_moment: DB.HashMap(.read_only), 174 arena: *std.heap.ArenaAllocator, 175 attachment_id: []const u8, 176 ) !?Record { 177 const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; 178 const records = try DB.HashMap(.read_only).init(records_cursor); 179 const record_cursor = try records.getCursor(hash.hashInt(hash_kind, attachment_id)) orelse return null; 180 const record_map = try DB.HashMap(.read_only).init(record_cursor); 181 return try evt.read(Record, DB, hash_kind, arena, record_map); 182 } 183