Source
pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath {
inline for (@typeInfo(uefi.DevicePath).@"union".fields) |ufield| {
const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield.name);
// Got the associated union type for self.type, now
// we need to initialize it and its subtype
if (self.type == enum_value) {
const subtype = self.initSubtype(ufield.type);
if (subtype) |sb| {
// e.g. return .{ .hardware = .{ .pci = @ptrCast(...) } }
return @unionInit(uefi.DevicePath, ufield.name, sb);
}
}
}
return null;
}