pub struct Promise<'a, T> { /* private fields */ }Expand description
Implementations§
Source§impl<T> Promise<'_, T>
impl<T> Promise<'_, T>
Sourcepub fn take(&mut self) -> Result<Option<T>, NodeError>
pub fn take(&mut self) -> Result<Option<T>, NodeError>
Try to receive the reply (non-blocking).
Returns Ok(Some(reply)) if the reply has arrived,
Ok(None) if still pending.
Take one message if the middleware has one — phase-379 W3.
Named take after rcl (rcl_take) and rclcpp (Subscription::take),
which spell the non-blocking receive that way — as does our own C
surface. NOT after rclrs: its subscription API is callback/worker-driven
and has no public polling counterpart at all (its take_* methods are
private), which is why the ledger records this as an extension against
the Rust reference rather than a match. take was Rust
channel vocabulary that reads as a different contract to a ROS 2 user:
both are non-blocking and both report emptiness without failing, so
nothing asked for the other word. Renamed as a clean break, no shim.
Sourcepub fn take_with_info(&mut self) -> Result<Option<(T, ServiceInfo)>, NodeError>
pub fn take_with_info(&mut self) -> Result<Option<(T, ServiceInfo)>, NodeError>
take, plus the reply’s ServiceInfo
— issue 2136.
rclrs’s client.call::<_, (Response, ServiceInfo)>(..), and upstream
rmw_take_response’s rmw_service_info_t: request_id is the
request this reply answers (this client’s GID and the sequence number
of its request), source_timestamp is when the SERVER sent the reply,
on its clock, and received_timestamp is when this client received
it. As for a service callback’s info, a field the backend cannot report
is None — see nros_core::ServiceInfo for which backend fills
which.
Source§impl<T> Promise<'_, T>
impl<T> Promise<'_, T>
Sourcepub fn wait(
&mut self,
executor: &mut Executor<'_>,
timeout: Duration,
) -> Result<T, NodeError>
pub fn wait( &mut self, executor: &mut Executor<'_>, timeout: Duration, ) -> Result<T, NodeError>
Block until the reply arrives, spinning the executor.
Internally calls executor.spin_once() in a loop until the reply
arrives or timeout_ms is exhausted. This is equivalent to the
manual spin+poll loop pattern but more ergonomic for simple use cases.
No borrow conflict: executor and self (which borrows the standalone
client) are disjoint objects.
§Errors
Returns NodeError::Timeout if the reply does not arrive within
timeout_ms milliseconds.
Sourcepub fn wait_with_info(
&mut self,
executor: &mut Executor<'_>,
timeout: Duration,
) -> Result<(T, ServiceInfo), NodeError>
pub fn wait_with_info( &mut self, executor: &mut Executor<'_>, timeout: Duration, ) -> Result<(T, ServiceInfo), NodeError>
wait, plus the reply’s
ServiceInfo — issue 2136. See
take_with_info.