summary refs log tree commit diff stats
path: root/docs/devel/rust.rst
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-02-14 11:13:53 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2025-03-06 12:44:46 +0100
commitf07a5674cf97b8473e5d06d7b1df9b51e97d553f (patch)
tree347e41799050dca47ddc510ff46d3a99cf0b5580 /docs/devel/rust.rst
parent0b9d05e3c98fe168f3502ccc422b9171467314fa (diff)
downloadfocaccia-qemu-f07a5674cf97b8473e5d06d7b1df9b51e97d553f.tar.gz
focaccia-qemu-f07a5674cf97b8473e5d06d7b1df9b51e97d553f.zip
rust: qemu_api_macros: add Wrapper derive macro
Add a derive macro that makes it easy to peel off all the layers of
specialness (UnsafeCell, MaybeUninit, etc.) and just get a pointer
to the wrapped type; and likewise add them back starting from a
*mut.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'docs/devel/rust.rst')
-rw-r--r--docs/devel/rust.rst8
1 files changed, 5 insertions, 3 deletions
diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst
index 784c3e40bd..88bdec1eb2 100644
--- a/docs/devel/rust.rst
+++ b/docs/devel/rust.rst
@@ -315,11 +315,13 @@ a raw pointer, for use in calls to C functions.  It can be used for
 example as follows::
 
     #[repr(transparent)]
-    #[derive(Debug)]
+    #[derive(Debug, qemu_api_macros::Wrapper)]
     pub struct Object(Opaque<bindings::Object>);
 
-The bindings will then manually check for the big QEMU lock with
-assertions, which allows the wrapper to be declared thread-safe::
+where the special ``derive`` macro provides useful methods such as
+``from_raw``, ``as_ptr`, ``as_mut_ptr`` and ``raw_get``.  The bindings will
+then manually check for the big QEMU lock with assertions, which allows
+the wrapper to be declared thread-safe::
 
     unsafe impl Send for Object {}
     unsafe impl Sync for Object {}