Skip to main content

RemoteMemoryRegion

Struct RemoteMemoryRegion 

Source
pub struct RemoteMemoryRegion { /* private fields */ }
Expand description

A handle to a memory region on a remote peer.

This struct provides the necessary coordinates (Address, Length, RKey) to perform One-Sided RDMA operations (Read/Write) against a remote node.

§The “Contiguous” Constraint

Unlike local operations which support Scatter/Gather (stitching fragmented memory together), remote operations are strictly contiguous.

  • Targeting — You specify a single starting address and a total length.
  • Behavior — The RDMA hardware reads or writes a continuous stream of bytes starting at that virtual address.

If you need to write to multiple non-contiguous buffers on a remote peer, you must issue multiple distinct RDMA Write operations.

§Safety and Responsibility

As discussed in the memory module, remote memory safety cannot be enforced by the Rust compiler.

  • Local SafetySafe. Even if this handle points to invalid memory, issuing an operation using it will only result in an error (or success), but will never corrupt local process memory.
  • Remote SafetyUnsafe. If you write to a RemoteMemoryRegion that has been deallocated on the remote peer, the remote NIC will unknowingly overwrite that memory. This causes Undefined Behavior on the remote peer.

Implementations§

Source§

impl RemoteMemoryRegion

Source

pub fn new(addr: u64, length: usize, rkey: u32) -> Self

Creates a new RemoteMemoryRegion from its raw components.

This is typically done after receiving these values from a remote peer via an out-of-band communication channel (like a TCP socket or UD message).

Source

pub fn address(&self) -> u64

Returns the starting virtual address of the remote memory.

Source

pub fn length(&self) -> usize

Returns the length of the remote memory region.

Note: This value is stored for client-side bounds checking and convenience. The actual hardware enforcement depends on how the memory was registered on the remote peer.

Source

pub fn rkey(&self) -> u32

Returns the Remote Key (rkey) authorizing access to this memory.

Source

pub fn sub_region(&self, offset: usize) -> Option<RemoteMemoryRegion>

Creates a generic sub-region derived from this one.

This acts as a handle to a specific slice of the remote memory, starting at offset bytes from the base address.

§Returns
  • Some(RemoteMemoryRegion) — If offset <= self.length. The new length is self.length - offset.
  • None — If offset > self.length.
Source

pub fn sub_region_unchecked(&self, offset: usize) -> RemoteMemoryRegion

Same as sub_region but without client-side bounds checking.

§Safety

This is safe from a Rust memory model perspective locally. If the calculated address/length falls outside the actual bounds registered on the remote peer, the RDMA hardware will reject the operation with a Remote Access Error.

Trait Implementations§

Source§

impl Clone for RemoteMemoryRegion

Source§

fn clone(&self) -> RemoteMemoryRegion

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RemoteMemoryRegion

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RemoteMemoryRegion

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RemoteMemoryRegion

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for RemoteMemoryRegion

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,