ibverbs_rs/ibverbs/work/success.rs
1/// Represents the successful completion of a Work Request.
2///
3/// This struct contains metadata returned by the hardware after an operation finishes successfully.
4/// It is typically extracted from a [`WorkCompletion`](crate::ibverbs::work::WorkCompletion).
5#[derive(Copy, Clone, Debug)]
6pub struct WorkSuccess {
7 imm_data: Option<u32>,
8 gathered_length: usize,
9}
10
11impl WorkSuccess {
12 pub(super) fn new(imm_data: Option<u32>, gathered_length: usize) -> Self {
13 Self {
14 imm_data,
15 gathered_length,
16 }
17 }
18}
19
20impl WorkSuccess {
21 /// Returns the immediate data (if any) received with this completion.
22 ///
23 /// This value is automatically converted from network byte order (Big Endian)
24 /// to the host's native byte order.
25 ///
26 /// Present if the sender used [`SendWorkRequest::with_immediate`](crate::ibverbs::work::SendWorkRequest::with_immediate)
27 /// or [`WriteWorkRequest::with_immediate`](crate::ibverbs::work::WriteWorkRequest::with_immediate).
28 pub fn immediate_data(&self) -> Option<u32> {
29 self.imm_data.map(u32::from_be)
30 }
31
32 /// Returns the number of local bytes modified by this operation.
33 ///
34 /// * **Receive** — The total bytes written into the local Scatter buffers.
35 /// * **RDMA Read** — The total bytes fetched from remote memory and written to local Scatter buffers.
36 /// * **Send / RDMA Write** — Zero (these operations do not modify local memory during completion).
37 pub fn gathered_length(&self) -> usize {
38 self.gathered_length
39 }
40}