Minimum information required to identify whether a package is an artifact of a given project.
pub const ProjectId = struct
pub const ProjectId = struct {
/// Bytes after name.len are set to zero.
padded_name: [32]u8,
fingerprint_id: u32,
pub fn init(name: []const u8, fingerprint_id: u32) ProjectId {
var padded_name: [32]u8 = @splat(0);
@memcpy(padded_name[0..name.len], name);
return .{
.padded_name = padded_name,
.fingerprint_id = fingerprint_id,
};
}
pub fn eql(a: *const ProjectId, b: *const ProjectId) bool {
return a.fingerprint_id == b.fingerprint_id and std.mem.eql(u8, &a.padded_name, &b.padded_name);
}
pub fn hash(a: *const ProjectId) u64 {
const x: u64 = @bitCast(a.padded_name[0..8].*);
return std.hash.int(x | a.fingerprint_id);
}
}