Skip to main content

remote_struct_array_field

Macro remote_struct_array_field 

Source
macro_rules! remote_struct_array_field {
    ($mr:expr, $Struct:ident, $index:expr, $field:ident) => { ... };
}
Expand description

Creates a RemoteMemoryRegion pointing to a specific field within an element of a remote array.

Assumes mr points to a remote array of Struct. Combines array indexing with field access: computes index * size_of::<Struct>() + offset_of!(Struct, field).

§Returns

  • Some(RemoteMemoryRegion) — A handle to the specified field within the index-th element.
  • None — If the byte offset computation overflows, exceeds the region length, or the resulting address overflows.

§Example

use ibverbs_rs::ibverbs::memory::RemoteMemoryRegion;
use ibverbs_rs::remote_struct_array_field;

#[repr(C)]
struct Node {
    id: u32,
    data: u64,
}

// Remote memory contains: [Node; 5]
let remote_mr = RemoteMemoryRegion::new(0x1000, 60, 0xABCD);

// Get a handle to the 'data' field of the 3rd Node (index 2)
let data_mr = remote_struct_array_field!(remote_mr, Node, 2_usize, data).unwrap();