[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 24/27] rust: qemu_api: add a documentation header for all modules
From: |
Paolo Bonzini |
Subject: |
[PULL 24/27] rust: qemu_api: add a documentation header for all modules |
Date: |
Thu, 13 Feb 2025 17:00:51 +0100 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
rust/qemu-api/src/assertions.rs | 4 ++++
rust/qemu-api/src/bindings.rs | 2 ++
rust/qemu-api/src/c_str.rs | 8 ++++++++
rust/qemu-api/src/offset_of.rs | 7 +++++++
rust/qemu-api/src/prelude.rs | 2 ++
rust/qemu-api/src/sysbus.rs | 2 ++
rust/qemu-api/src/zeroable.rs | 2 ++
7 files changed, 27 insertions(+)
diff --git a/rust/qemu-api/src/assertions.rs b/rust/qemu-api/src/assertions.rs
index 6e420469806..fa1a18de6fe 100644
--- a/rust/qemu-api/src/assertions.rs
+++ b/rust/qemu-api/src/assertions.rs
@@ -2,9 +2,13 @@
// Author(s): Paolo Bonzini <pbonzini@redhat.com>
// SPDX-License-Identifier: GPL-2.0-or-later
+#![doc(hidden)]
//! This module provides macros to check the equality of types and
//! the type of `struct` fields. This can be useful to ensure that
//! types match the expectations of C code.
+//!
+//! Documentation is hidden because it only exposes macros, which
+//! are exported directly from `qemu_api`.
// Based on https://stackoverflow.com/questions/64251852/x/70978292#70978292
// (stackoverflow answers are released under MIT license).
diff --git a/rust/qemu-api/src/bindings.rs b/rust/qemu-api/src/bindings.rs
index b71220113ef..d2868639ff6 100644
--- a/rust/qemu-api/src/bindings.rs
+++ b/rust/qemu-api/src/bindings.rs
@@ -15,6 +15,8 @@
clippy::missing_safety_doc
)]
+//! `bindgen`-generated declarations.
+
#[cfg(MESON)]
include!("bindings.inc.rs");
diff --git a/rust/qemu-api/src/c_str.rs b/rust/qemu-api/src/c_str.rs
index 4cd96da0b45..3fa61b59c76 100644
--- a/rust/qemu-api/src/c_str.rs
+++ b/rust/qemu-api/src/c_str.rs
@@ -2,6 +2,14 @@
// Author(s): Paolo Bonzini <pbonzini@redhat.com>
// SPDX-License-Identifier: GPL-2.0-or-later
+#![doc(hidden)]
+//! This module provides a macro to define a constant of type
+//! [`CStr`](std::ffi::CStr), for compatibility with versions of
+//! Rust that lack `c""` literals.
+//!
+//! Documentation is hidden because it only exposes macros, which
+//! are exported directly from `qemu_api`.
+
#[macro_export]
/// Given a string constant _without_ embedded or trailing NULs, return
/// a `CStr`.
diff --git a/rust/qemu-api/src/offset_of.rs b/rust/qemu-api/src/offset_of.rs
index 075e98f986b..373229bbde9 100644
--- a/rust/qemu-api/src/offset_of.rs
+++ b/rust/qemu-api/src/offset_of.rs
@@ -1,5 +1,12 @@
// SPDX-License-Identifier: MIT
+#![doc(hidden)]
+//! This module provides macros that emulate the functionality of
+//! `core::mem::offset_of` on older versions of Rust.
+//!
+//! Documentation is hidden because it only exposes macros, which
+//! are exported directly from `qemu_api`.
+
/// This macro provides the same functionality as `core::mem::offset_of`,
/// except that only one level of field access is supported. The declaration
/// of the struct must be wrapped with `with_offsets! { }`.
diff --git a/rust/qemu-api/src/prelude.rs b/rust/qemu-api/src/prelude.rs
index 254edb476dd..fbf0ee23e0b 100644
--- a/rust/qemu-api/src/prelude.rs
+++ b/rust/qemu-api/src/prelude.rs
@@ -2,6 +2,8 @@
// Author(s): Paolo Bonzini <pbonzini@redhat.com>
// SPDX-License-Identifier: GPL-2.0-or-later
+//! Commonly used traits and types for QEMU.
+
pub use crate::bitops::IntegerExt;
pub use crate::cell::BqlCell;
diff --git a/rust/qemu-api/src/sysbus.rs b/rust/qemu-api/src/sysbus.rs
index 1f66a5f1e09..fa36e12178f 100644
--- a/rust/qemu-api/src/sysbus.rs
+++ b/rust/qemu-api/src/sysbus.rs
@@ -2,6 +2,8 @@
// Author(s): Paolo Bonzini <pbonzini@redhat.com>
// SPDX-License-Identifier: GPL-2.0-or-later
+//! Bindings to access `sysbus` functionality from Rust.
+
use std::{ffi::CStr, ptr::addr_of_mut};
pub use bindings::{SysBusDevice, SysBusDeviceClass};
diff --git a/rust/qemu-api/src/zeroable.rs b/rust/qemu-api/src/zeroable.rs
index cd424e6ea05..a2356cb2f24 100644
--- a/rust/qemu-api/src/zeroable.rs
+++ b/rust/qemu-api/src/zeroable.rs
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
+//! Defines a trait for structs that can be safely initialized with zero bytes.
+
/// Encapsulates the requirement that
/// `MaybeUninit::<Self>::zeroed().assume_init()` does not cause undefined
/// behavior. This trait in principle could be implemented as just:
--
2.48.1
- [PULL 14/27] i386/fw_cfg: move hpet_cfg definition to hpet.c, (continued)
- [PULL 14/27] i386/fw_cfg: move hpet_cfg definition to hpet.c, Paolo Bonzini, 2025/02/13
- [PULL 16/27] rust/irq: Add a helper to convert [InterruptSource] to pointer, Paolo Bonzini, 2025/02/13
- [PULL 19/27] rust: add bindings for timer, Paolo Bonzini, 2025/02/13
- [PULL 20/27] rust/timer/hpet: define hpet_fw_cfg, Paolo Bonzini, 2025/02/13
- [PULL 23/27] i386: enable rust hpet for pc when rust is enabled, Paolo Bonzini, 2025/02/13
- [PULL 22/27] rust/timer/hpet: add qom and qdev APIs support, Paolo Bonzini, 2025/02/13
- [PULL 18/27] rust: add bindings for memattrs, Paolo Bonzini, 2025/02/13
- [PULL 21/27] rust/timer/hpet: add basic HPET timer and HPETState, Paolo Bonzini, 2025/02/13
- [PULL 24/27] rust: qemu_api: add a documentation header for all modules,
Paolo Bonzini <=
- [PULL 25/27] rust: vmstate: remove redundant link targets, Paolo Bonzini, 2025/02/13
- [PULL 26/27] rust: fix doctests, Paolo Bonzini, 2025/02/13
- [PULL 27/27] ui/sdl2: reenable the SDL2 Windows keyboard hook procedure, Paolo Bonzini, 2025/02/13
- Re: [PULL 00/27] rust, Windows patches for 2025-02-13, Stefan Hajnoczi, 2025/02/17