Skip to main content

GatherElement

Struct GatherElement 

Source
pub struct GatherElement<'a> { /* private fields */ }
Expand description

A Gather Element for outgoing RDMA operations.

§Purpose

A GatherElement represents a slice of registered memory that the NIC will read from to send over the network. The NIC “gathers” data from a list of these elements into a single continuous stream.

§Usage

Use this for operations where the local node sends data:

  • Send Requests — The payload to send.
  • RDMA Write — The local source buffer.

§Safety and Lifetimes

This struct enforces Rust’s borrowing rules at the hardware level:

  • Immutable Access — It holds a &'a [u8] to the data, allowing shared access but preventing mutation while the operation is pending.
  • Liveness — It holds a reference to the MemoryRegion, ensuring the registration remains valid.

See the memory module for a detailed explanation of the safety architecture.

Implementations§

Source§

impl<'a> GatherElement<'a>

Source

pub fn new(mr: &'a MemoryRegion, data: &'a [u8]) -> Self

Creates a new gather element.

In debug builds, this performs additional validation before constructing the element. In optimized/release builds, these validations are not executed by default because they are implemented using debug_assert!.

§Panics

Panics in debug builds if any of the following conditions are violated:

  1. The data slice is fully contained within the mr’s address range.
  2. The data length fits in a u32 (hardware limit).

For a version that always validates and returns an error instead of panicking, use Self::new_checked.

Source

pub fn new_checked( mr: &'a MemoryRegion, data: &'a [u8], ) -> Result<Self, ScatterGatherElementError>

Creates a new Gather Element with bounds checking.

§Checks

This method validates that:

  1. The data slice is fully contained within the mr’s address range.
  2. The data length fits in a u32 (hardware limit).
Source

pub fn new_unchecked(mr: &'a MemoryRegion, data: &'a [u8]) -> Self

Creates a new Gather Element without bounds checking.

§Safety

This method is safe to call from a Rust memory-safety perspective. If the slice is outside the MR, the hardware will detect this during RDMA operations and fail with a Local Protection Error.

§Warning

If data.len() exceeds u32::MAX, the length stored in the SGE will silently wrap. Only the wrapped (truncated) number of bytes will be posted to the hardware. Use new_checked to catch this at the cost of a bounds check.

Trait Implementations§

Source§

impl<'a> Clone for GatherElement<'a>

Source§

fn clone(&self) -> GatherElement<'a>

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<'a> Debug for GatherElement<'a>

Source§

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

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

impl<'a> Copy for GatherElement<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for GatherElement<'a>

§

impl<'a> RefUnwindSafe for GatherElement<'a>

§

impl<'a> Send for GatherElement<'a>

§

impl<'a> Sync for GatherElement<'a>

§

impl<'a> Unpin for GatherElement<'a>

§

impl<'a> UnsafeUnpin for GatherElement<'a>

§

impl<'a> UnwindSafe for GatherElement<'a>

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.