rust: qemu_api: add a documentation header for all modules

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2025-01-30 11:11:18 +01:00
parent d128c341a7
commit ebacd14a6f
7 changed files with 27 additions and 0 deletions

View file

@ -2,9 +2,13 @@
// Author(s): Paolo Bonzini <pbonzini@redhat.com> // Author(s): Paolo Bonzini <pbonzini@redhat.com>
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#![doc(hidden)]
//! This module provides macros to check the equality of types and //! This module provides macros to check the equality of types and
//! the type of `struct` fields. This can be useful to ensure that //! the type of `struct` fields. This can be useful to ensure that
//! types match the expectations of C code. //! 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 // Based on https://stackoverflow.com/questions/64251852/x/70978292#70978292
// (stackoverflow answers are released under MIT license). // (stackoverflow answers are released under MIT license).

View file

@ -15,6 +15,8 @@
clippy::missing_safety_doc clippy::missing_safety_doc
)] )]
//! `bindgen`-generated declarations.
#[cfg(MESON)] #[cfg(MESON)]
include!("bindings.inc.rs"); include!("bindings.inc.rs");

View file

@ -2,6 +2,14 @@
// Author(s): Paolo Bonzini <pbonzini@redhat.com> // Author(s): Paolo Bonzini <pbonzini@redhat.com>
// SPDX-License-Identifier: GPL-2.0-or-later // 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] #[macro_export]
/// Given a string constant _without_ embedded or trailing NULs, return /// Given a string constant _without_ embedded or trailing NULs, return
/// a `CStr`. /// a `CStr`.

View file

@ -1,5 +1,12 @@
// SPDX-License-Identifier: MIT // 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`, /// This macro provides the same functionality as `core::mem::offset_of`,
/// except that only one level of field access is supported. The declaration /// except that only one level of field access is supported. The declaration
/// of the struct must be wrapped with `with_offsets! { }`. /// of the struct must be wrapped with `with_offsets! { }`.

View file

@ -2,6 +2,8 @@
// Author(s): Paolo Bonzini <pbonzini@redhat.com> // Author(s): Paolo Bonzini <pbonzini@redhat.com>
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
//! Commonly used traits and types for QEMU.
pub use crate::bitops::IntegerExt; pub use crate::bitops::IntegerExt;
pub use crate::cell::BqlCell; pub use crate::cell::BqlCell;

View file

@ -2,6 +2,8 @@
// Author(s): Paolo Bonzini <pbonzini@redhat.com> // Author(s): Paolo Bonzini <pbonzini@redhat.com>
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
//! Bindings to access `sysbus` functionality from Rust.
use std::{ffi::CStr, ptr::addr_of_mut}; use std::{ffi::CStr, ptr::addr_of_mut};
pub use bindings::{SysBusDevice, SysBusDeviceClass}; pub use bindings::{SysBusDevice, SysBusDeviceClass};

View file

@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // 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 /// Encapsulates the requirement that
/// `MaybeUninit::<Self>::zeroed().assume_init()` does not cause undefined /// `MaybeUninit::<Self>::zeroed().assume_init()` does not cause undefined
/// behavior. This trait in principle could be implemented as just: /// behavior. This trait in principle could be implemented as just: