#[pin_data]Expand description
Used to specify the pinning information of the fields of a struct.
This is somewhat similar in purpose as
pin-project-lite.
Place this macro on a struct definition and then #[pin] in front of the attributes of each
field you want to structurally pin.
This macro enables the use of the pin_init! macro. When pin-initializing a struct,
then #[pin] directs the type of initializer that is required.
If your struct implements Drop, then you need to add PinnedDrop as arguments to this
macro, and change your Drop implementation to PinnedDrop annotated with
#[pinned_drop], since dropping pinned values requires extra care.
ยงExamples
#[pin_data]
struct DriverData {
#[pin]
queue: Mutex<KVec<Command>>,
buf: KBox<[u8; 1024 * 1024]>,
}use kernel::macros::{pin_data, pinned_drop};
#[pin_data(PinnedDrop)]
struct DriverData {
#[pin]
queue: Mutex<KVec<Command>>,
buf: KBox<[u8; 1024 * 1024]>,
raw_info: *mut Info,
}
#[pinned_drop]
impl PinnedDrop for DriverData {
fn drop(self: Pin<&mut Self>) {
unsafe { bindings::destroy_info(self.raw_info) };
}
}