pub struct ReceiptHandle { /* private fields */ }Expand description
A pending receipt confirmation for a frame sent with
Connection::send_frame_with_receipt.
The handle owns the receiving half of the confirmation channel from the
moment the frame is queued for sending. A RECEIPT that arrives before
wait is called is therefore buffered in the channel
rather than dropped, so the confirmation cannot be lost to a fast broker.
Handles are independent, so several frames may be sent before any of them is awaited:
let mut handles = Vec::new();
for order in orders {
handles.push(conn.send_frame_with_receipt(order).await?);
}
for handle in handles {
handle.wait(Duration::from_secs(5)).await?;
}Implementations§
Source§impl ReceiptHandle
impl ReceiptHandle
Sourcepub fn receipt_id(&self) -> &str
pub fn receipt_id(&self) -> &str
The receipt id the client generated for this frame.
This is the value sent in the frame’s receipt header and echoed by the
broker in the receipt-id header of its response.
Sourcepub async fn wait(self, timeout: Duration) -> Result<(), ConnError>
pub async fn wait(self, timeout: Duration) -> Result<(), ConnError>
Wait for the broker to confirm the frame.
§Parameters
timeout: maximum time to wait for the broker’s response.
§Returns
Ok(()) if the broker sent a RECEIPT, Err(ConnError::FrameRejected)
if it answered with an ERROR carrying this receipt id, or
Err(ConnError::ReceiptTimeout) if the timeout expired first.