╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Attachment.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
142 .tree_entries = &.{.{ .blob = blob }}, 143 .event = .{ .attach = .{ .target_id = target_id.* } }, 144 }}); 145 return event_id; 146 } 147 148 // read an attachment by event id, or null if the id isn't a known attachment. 149 // field byte slices are allocated in `arena`. 150 pub fn readById( 151 comptime DB: type, 152 comptime hash_kind: hash.HashKind, 153 haxy_moment: DB.HashMap(.read_only), 154 arena: *std.heap.ArenaAllocator, 155 attachment_id: []const u8, 156 ) !?Record { 157 const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; 158 const records = try DB.HashMap(.read_only).init(records_cursor); 159 const record_cursor = try records.getCursor(hash.hashInt(hash_kind, attachment_id)) orelse return null; 160 const record_map = try DB.HashMap(.read_only).init(record_cursor); 161 return try evt.read(Record, DB, hash_kind, arena, record_map); 162 } 163