Re: [RFC PATCH 1/3] rust: implement wrapper for acpi_object

From: Gladyshev Ilya

Date: Mon Dec 22 2025 - 16:48:00 EST


On 12/22/25 14:35, Danilo Krummrich wrote:
+acpi_object_subtype!(AcpiInteger
+ <- (ACPI_TYPE_INTEGER, integer, bindings::acpi_object__bindgen_ty_1));
+acpi_object_subtype!(AcpiString
+ <- (ACPI_TYPE_STRING, string, bindings::acpi_object__bindgen_ty_2));
+acpi_object_subtype!(AcpiBuffer
+ <- (ACPI_TYPE_BUFFER, buffer, bindings::acpi_object__bindgen_ty_3));
+acpi_object_subtype!(AcpiPackage
+ <- (ACPI_TYPE_PACKAGE, package, bindings::acpi_object__bindgen_ty_4));
+acpi_object_subtype!(AcpiReference
+ <- (ACPI_TYPE_LOCAL_REFERENCE, reference, bindings::acpi_object__bindgen_ty_5));
+acpi_object_subtype!(AcpiProcessor
+ <- (ACPI_TYPE_PROCESSOR, processor, bindings::acpi_object__bindgen_ty_6));
+acpi_object_subtype!(AcpiPowerResource
+ <- (ACPI_TYPE_POWER, power_resource, bindings::acpi_object__bindgen_ty_7));
+
+impl AcpiBuffer {
+ /// Get Buffer's content
+ pub fn payload(&self) -> &[u8] {
+ // SAFETY: (pointer, length) indeed represents byte slice
+ unsafe { ::core::slice::from_raw_parts(self.0.pointer, self.0.length as usize) }
+ }
+}

What about the values of the other types? How are they accessed?

I couldn't really decide between implementing all types or only the one needed... Probably, I should provide simple implementations for all the others, I will fix that.

Also, I think it would be better to use a Deref impl rather than a method.

Wouldn't it be confusing to overload Deref on a non "pointer-like" type just for an implicit cast?

Overall, thank you for your patience and review. I will fix the other comments from both of your emails.