Il mer 18 dic 2024, 07:50 Zhao Liu <zhao1....@intel.com> ha scritto: > Am I using the wrong terminology? Function pointers in a structure should > be called a vtable, rather than callbacks (for example, methods in > TypeInfo, > read/write methods in MemoryRegionOps). Callbacks are typically function > pointers used as function parameters (for example, timer/gpio). So, is the > callback implementation here only used for the latter case? >
The callback implementation is not used for QOM indeed. In that case, using FnCall would require something like const UNPARENT: impl FnCall((&Self,)); which does not exist as far as I know? MemoryRegionOps is a mix of callbacks and a vtable. From the Rust point of view, with the API that uses the builder pattern, MemoryRegionOps (and VMStateDescription too) would be closer to callbacks. Instead when you use traits and fill in the class object, that's clearly a vtable. But in this sense MemoryRegionOps do not need optional callbacks. You just don't call the ops.read() method if you don't need to set a read callback for example. So I am not sure if anything that is planned right now needs the optional callbacks. It's good to have the patch for the future but it's not necessary right now. Paolo