From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-rust@nongnu.org
Subject: [PATCH 3/8] hwcore: add prelude
Date: Mon, 17 Nov 2025 08:42:33 +0100 [thread overview]
Message-ID: <20251117074239.190424-4-pbonzini@redhat.com> (raw)
In-Reply-To: <20251117074239.190424-1-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
rust/hw/char/pl011/src/device.rs | 5 +----
rust/hw/core/meson.build | 1 +
rust/hw/core/src/lib.rs | 5 +++++
rust/hw/core/src/prelude.rs | 14 ++++++++++++++
rust/hw/core/tests/tests.rs | 2 +-
rust/hw/timer/hpet/src/device.rs | 5 +----
6 files changed, 23 insertions(+), 9 deletions(-)
create mode 100644 rust/hw/core/src/prelude.rs
diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs
index b7e8e393d2e..164f27d5bb2 100644
--- a/rust/hw/char/pl011/src/device.rs
+++ b/rust/hw/char/pl011/src/device.rs
@@ -7,10 +7,7 @@
use bql::BqlRefCell;
use chardev::{CharFrontend, Chardev, Event};
use common::prelude::*;
-use hwcore::{
- Clock, ClockEvent, DeviceImpl, DeviceMethods, DeviceState, IRQState, InterruptSource,
- ResetType, ResettablePhasesImpl, SysBusDevice, SysBusDeviceImpl, SysBusDeviceMethods,
-};
+use hwcore::{prelude::*, ClockEvent, IRQState};
use migration::{
self, impl_vmstate_forward, impl_vmstate_struct, vmstate_fields, vmstate_of,
vmstate_subsections, vmstate_unused, VMStateDescription, VMStateDescriptionBuilder,
diff --git a/rust/hw/core/meson.build b/rust/hw/core/meson.build
index 1560dd20c6b..fa1765a2302 100644
--- a/rust/hw/core/meson.build
+++ b/rust/hw/core/meson.build
@@ -51,6 +51,7 @@ _hwcore_rs = static_library(
'src/lib.rs',
'src/bindings.rs',
'src/irq.rs',
+ 'src/prelude.rs',
'src/qdev.rs',
'src/sysbus.rs',
],
diff --git a/rust/hw/core/src/lib.rs b/rust/hw/core/src/lib.rs
index b40801eb843..491743d2b9d 100644
--- a/rust/hw/core/src/lib.rs
+++ b/rust/hw/core/src/lib.rs
@@ -8,6 +8,11 @@
mod irq;
pub use irq::*;
+// preserve one-item-per-"use" syntax, it is clearer
+// for prelude-like modules
+#[rustfmt::skip]
+pub mod prelude;
+
mod qdev;
pub use qdev::*;
diff --git a/rust/hw/core/src/prelude.rs b/rust/hw/core/src/prelude.rs
new file mode 100644
index 00000000000..c544c317b39
--- /dev/null
+++ b/rust/hw/core/src/prelude.rs
@@ -0,0 +1,14 @@
+//! Essential types and traits intended for blanket imports.
+
+pub use crate::qdev::Clock;
+pub use crate::qdev::DeviceState;
+pub use crate::qdev::DeviceImpl;
+pub use crate::qdev::DeviceMethods;
+pub use crate::qdev::ResettablePhasesImpl;
+pub use crate::qdev::ResetType;
+
+pub use crate::sysbus::SysBusDevice;
+pub use crate::sysbus::SysBusDeviceImpl;
+pub use crate::sysbus::SysBusDeviceMethods;
+
+pub use crate::irq::InterruptSource;
diff --git a/rust/hw/core/tests/tests.rs b/rust/hw/core/tests/tests.rs
index 247d812866d..b39d1501d5b 100644
--- a/rust/hw/core/tests/tests.rs
+++ b/rust/hw/core/tests/tests.rs
@@ -5,7 +5,7 @@
use std::{ffi::CStr, ptr::addr_of};
use bql::BqlCell;
-use hwcore::{DeviceImpl, DeviceState, ResettablePhasesImpl, SysBusDevice};
+use hwcore::prelude::*;
use migration::{VMStateDescription, VMStateDescriptionBuilder};
use qom::{prelude::*, ObjectImpl, ParentField};
use util::bindings::{module_call_init, module_init_type};
diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/device.rs
index e9c7afa24d5..7ab9897cdfb 100644
--- a/rust/hw/timer/hpet/src/device.rs
+++ b/rust/hw/timer/hpet/src/device.rs
@@ -12,10 +12,7 @@
use bql::{BqlCell, BqlRefCell};
use common::prelude::*;
-use hwcore::{
- DeviceImpl, DeviceMethods, DeviceState, InterruptSource, ResetType, ResettablePhasesImpl,
- SysBusDevice, SysBusDeviceImpl, SysBusDeviceMethods,
-};
+use hwcore::prelude::*;
use migration::{
self, impl_vmstate_struct, vmstate_fields, vmstate_of, vmstate_subsections, vmstate_validate,
VMStateDescription, VMStateDescriptionBuilder,
--
2.51.1
next prev parent reply other threads:[~2025-11-17 7:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 7:42 [PATCH 0/8] rust: add preludes to all crates Paolo Bonzini
2025-11-17 7:42 ` [PATCH 1/8] util: add prelude Paolo Bonzini
2025-11-17 7:42 ` [PATCH 2/8] common: " Paolo Bonzini
2025-11-17 7:42 ` Paolo Bonzini [this message]
2025-11-17 7:42 ` [PATCH 4/8] migration: " Paolo Bonzini
2025-11-17 7:42 ` [PATCH 5/8] chardev: " Paolo Bonzini
2025-11-17 7:42 ` [PATCH 6/8] bql: " Paolo Bonzini
2025-11-17 7:42 ` [PATCH 7/8] system: " Paolo Bonzini
2025-11-17 7:42 ` [PATCH 8/8] qom: add more to the prelude Paolo Bonzini
2025-11-17 8:03 ` [PATCH 0/8] rust: add preludes to all crates Marc-André Lureau
2025-11-17 8:36 ` Paolo Bonzini
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=20251117074239.190424-4-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/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).