rust: qdev: move device_class_init! body to generic function, ClassInitImpl implement...
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 28 Oct 2024 09:29:27 +0000 (10:29 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 10 Dec 2024 17:49:26 +0000 (18:49 +0100)
commit8c80c472da6342c5924bc4ea7e87c77ca61477b8
tree4343d0f5b9df3868acc1b3e2c272154da39408f8
parentc6c4f3e0d90990c642523c087482eac3f42566c1
rust: qdev: move device_class_init! body to generic function, ClassInitImpl implementation to macro

Use a trait to access the former parameters to device_class_init!.
This allows hiding the details of the class_init implementation behind
a generic function and makes higher-level functionality available from
qemu_api.

The implementation of ClassInitImpl is then the same for all devices and
is easily macroized.  Later on, we can remove the need to implement
ClassInitImpl by hand for all device types, and stop making
rust_device_class_init<>() public.

While at it, document the members of DeviceImpl.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/hw/char/pl011/src/device.rs
rust/hw/char/pl011/src/device_class.rs
rust/qemu-api/src/device_class.rs
rust/qemu-api/tests/tests.rs