Skip to main content

ScatterElement

Struct ScatterElement 

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

A Scatter Element for incoming RDMA operations.

§Purpose

A ScatterElement represents a slice of registered memory that the NIC will write into when receiving from the network. The NIC “scatters” the incoming stream across a list of these elements.

§Usage

Use this for operations where the local node receives data:

  • Receive Requests — The buffer to fill with incoming data.
  • RDMA Read — The local destination buffer.

§Safety and Lifetimes

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

  • Exclusive Access — It holds a &'a mut [u8] to the data, ensuring no other part of the program can read or write this memory while the NIC is writing to it.
  • 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> ScatterElement<'a>

Source

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

Creates a new scatter 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 mut [u8], ) -> Result<Self, ScatterGatherElementError>

Creates a new Scatter 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.
Source

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

Creates a new Scatter 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> Debug for ScatterElement<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ScatterElement<'a>

§

impl<'a> RefUnwindSafe for ScatterElement<'a>

§

impl<'a> Send for ScatterElement<'a>

§

impl<'a> Sync for ScatterElement<'a>

§

impl<'a> Unpin for ScatterElement<'a>

§

impl<'a> UnsafeUnpin for ScatterElement<'a>

§

impl<'a> !UnwindSafe for ScatterElement<'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> 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, 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.