pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath self: *const DevicePath84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath {
const u_info = @typeInfo(uefi.DevicePath).@"union";
inline for (u_info.field_names, u_info.field_types) |ufield_name, ufield_type| {
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;
}