On Wed, Dec 18, 2024 at 08:32:59AM +0100, Paolo Bonzini wrote: > Date: Wed, 18 Dec 2024 08:32:59 +0100 > From: Paolo Bonzini <pbonz...@redhat.com> > Subject: Re: [PATCH 26/26] rust: callbacks: allow passing optional > callbacks as () > > 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?
Yes, it's incorrect. (I know you have some magic, so I have this question to see your idea.) > 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. Thanks for your explaination. I agree your plan. I also think it will be useful in the future. Regards, Zhao