macro_rules! remote_struct_field {
($mr:expr, $Struct:ident :: $field:ident) => { ... };
}Expand description
Creates a RemoteMemoryRegion pointing to a specific field of a remote struct.
Assumes mr points to the start of a remote Struct. Uses offset_of! to
compute the field’s byte offset and returns a sub-region handle.
§Returns
Some(RemoteMemoryRegion)— A handle to the specified field.None— If the field offset exceeds the region length or the resulting address overflows.
§Example
use ibverbs_rs::ibverbs::memory::RemoteMemoryRegion;
use ibverbs_rs::remote_struct_field;
#[repr(C)]
struct Packet {
header: u32,
payload: [u8; 1024],
}
// Remote memory contains a `Packet`
let remote_mr = RemoteMemoryRegion::new(0x1000, 1028, 0xABCD);
// Get a handle to the 'payload' field
let payload_mr = remote_struct_field!(remote_mr, Packet::payload).unwrap();
assert_eq!(payload_mr.address(), 0x1004);