Re: [PATCH v2 00/16] rust: QObject and QAPI bindings

Markus Armbruster
2026-02-26T12:43:10Z

Paolo Bonzini <pbonzini@redhat.com> writes:

> On 2/24/26 15:06, Markus Armbruster wrote:
>> Paolo Bonzini <pbonzini@redhat.com> writes:
>>
>>> This adds two related parts of the Rust bindings:
>>
>> [...]
>>
>>> docs/devel/rust.rst | 1 +
>>> meson.build | 4 +-
>>> include/qobject/qobject.h | 5 +-
>>> rust/util/wrapper.h | 8 +
>>> qapi/meson.build | 9 +
>>> rust/Cargo.lock | 2 +
>>> rust/Cargo.toml | 2 +
>>> rust/meson.build | 4 +
>>> rust/tests/meson.build | 21 +-
>>> rust/tests/tests/integration.rs | 2 +
>>> rust/tests/tests/qapi.rs | 444 +++++++++++++
>>> rust/util/Cargo.toml | 2 +
>>> rust/util/meson.build | 30 +-
>>> rust/util/src/lib.rs | 4 +
>>> rust/util/src/qobject/deserialize.rs | 134 ++++
>>> rust/util/src/qobject/deserializer.rs | 371 +++++++++++
>>
>> Are you sure having two source filenames differ in just one character is
>> a good idea?
>>
>>> rust/util/src/qobject/error.rs | 58 ++
>>> rust/util/src/qobject/mod.rs | 383 ++++++++++++
>>> rust/util/src/qobject/serialize.rs | 59 ++
>>> rust/util/src/qobject/serializer.rs | 585 ++++++++++++++++++
>>
>> Likewise.
>
> I feel and share your pain... That's how serde calls the things ("-er"
> for the struct and verb for the trait) and I cannot really thing of a
> different naming for files.
>
> I thought of renaming serializer.rs to to_qobject.rs, and
> deserializer.rs to from_qobject.rs. However, that doesn't work out
> because I want "qobject::to_object" to be the function, not the module
> containing to_qobject() and Serializer.
>
> serde_json places the struct and trait in the same file (e.g.
> https://github.com/serde-rs/json/blob/master/src/value/ser.rs). I can
> do that if you prefer it that way.

Any drawbacks?

You decide!

> Paolo
>
>> These caused a bit of friction in review already...
>>
>> …