qemu-rust.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org
Subject: Re: [PATCH 3/5] rust: vmstate: convert to use builder pattern
Date: Tue, 6 May 2025 12:33:17 +0200	[thread overview]
Message-ID: <CABgObfYAw92Fy8PUPEf5=vJG2N_O3-pt754QoFLLgfQu9JB-0A@mail.gmail.com> (raw)
In-Reply-To: <aBncq8KFTgzcT3jv@intel.com>

On Tue, May 6, 2025 at 11:35 AM Zhao Liu <zhao1.liu@intel.com> wrote:
>
> > +unsafe extern "C" fn vmstate_pre_load_cb<
> > +    T,
> > +    F: for<'a> FnCall<(&'a T,), Result<(), impl Into<Errno>>>,
> > +>(
> > +    opaque: *mut c_void,
> > +) -> c_int {
> > +    // SAFETY: assumes vmstate_struct! is used correctly
> > +    let result = F::call((unsafe { &*(opaque.cast::<T>()) },));
> > +    into_neg_errno(result)
>
> Thanks! Now I see why you used io::ErrorKind.
>
> > +}
>
> ...
>
> > +    #[must_use]
> > +    pub const fn pre_load<F: for<'a> FnCall<(&'a T,), Result<(), impl Into<Errno>>>>(
> > +        mut self,
> > +        _f: &F,
> > +    ) -> Self {
>
> Do we need to assert F is not ()?
>
> const { assert!(F::IS_SOME) };

A NULL callback (i.e. ".pre_load(())") is a bit weird but acceptable.
So the assertion if not needed, but indeed there should be an "if"
that stores "ptr::null()" instead of vmstate_pre_load_cb::<F>.

Paolo



  reply	other threads:[~2025-05-06 10:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05 10:08 [PATCH preview 0/5] rust: allow minimum version of 1.83 Paolo Bonzini
2025-05-05 10:08 ` [PATCH 1/5] meson, cargo: require Rust 1.83.0 Paolo Bonzini
2025-05-05 10:08 ` [PATCH 2/5] rust: use inline const expressions Paolo Bonzini
2025-05-06  9:11   ` Zhao Liu
2025-05-06 10:56     ` Paolo Bonzini
2025-05-05 10:08 ` [PATCH 3/5] rust: vmstate: convert to use builder pattern Paolo Bonzini
2025-05-06  9:55   ` Zhao Liu
2025-05-06 10:33     ` Paolo Bonzini [this message]
2025-05-05 10:08 ` [PATCH 4/5] rust: vmstate: use const_refs_to_static Paolo Bonzini
2025-05-07  7:59   ` Zhao Liu
2025-05-05 10:08 ` [PATCH 5/5] rust: qdev: const_refs_to_static Paolo Bonzini
2025-05-06  8:56 ` [PATCH preview 0/5] rust: allow minimum version of 1.83 Zhao Liu
2025-05-06  8:43   ` Paolo Bonzini
2025-05-06  9:26     ` Zhao Liu
2025-05-06  9:44       ` Daniel P. Berrangé
2025-05-06  9:48       ` Daniel P. Berrangé
2025-05-06 10:54         ` Paolo Bonzini
2025-05-06 11:52           ` Daniel P. Berrangé
2025-05-06 13:41             ` Paolo Bonzini
2025-05-06 15:56           ` Zhao Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABgObfYAw92Fy8PUPEf5=vJG2N_O3-pt754QoFLLgfQu9JB-0A@mail.gmail.com' \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-rust@nongnu.org \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).