qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 26/26] rust: callbacks: allow passing optional callbacks as (


From: Paolo Bonzini
Subject: Re: [PATCH 26/26] rust: callbacks: allow passing optional callbacks as ()
Date: Wed, 18 Dec 2024 08:32:59 +0100



Il mer 18 dic 2024, 07:50 Zhao Liu <zhao1.liu@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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]