[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 26/26] rust: callbacks: allow passing optional callbacks as (
From: |
Zhao Liu |
Subject: |
Re: [PATCH 26/26] rust: callbacks: allow passing optional callbacks as () |
Date: |
Wed, 18 Dec 2024 23:09:55 +0800 |
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 <pbonzini@redhat.com>
> Subject: Re: [PATCH 26/26] rust: callbacks: allow passing optional
> callbacks as ()
>
> 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?
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
Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Zhao Liu, 2024/12/18
[PATCH 26/26] rust: callbacks: allow passing optional callbacks as (), Paolo Bonzini, 2024/12/09
[PATCH 23/26] rust: qom: add initial subset of methods on Object, Paolo Bonzini, 2024/12/09
[PATCH 21/26] rust: tests: allow writing more than one test, Paolo Bonzini, 2024/12/09
[PATCH 12/26] rust: qdev: move bridge for realize and reset functions out of pl011, Paolo Bonzini, 2024/12/09
[PATCH 18/26] rust: qom: add possibility of overriding unparent, Paolo Bonzini, 2024/12/09