pub struct Client<T>where
T: Service,{ /* private fields */ }
Expand description
Main class responsible for sending requests to a ROS service.
The only available way to instantiate clients is via Node::create_client
, this is to
ensure that Node
s can track all the clients that have been created.
Implementations§
Source§impl<T> Client<T>where
T: Service,
impl<T> Client<T>where
T: Service,
Sourcepub fn async_send_request_with_callback<'a, M: MessageCow<'a, T::Request>, F>(
&self,
message: M,
callback: F,
) -> Result<(), RclrsError>
pub fn async_send_request_with_callback<'a, M: MessageCow<'a, T::Request>, F>( &self, message: M, callback: F, ) -> Result<(), RclrsError>
Sends a request with a callback to be called with the response.
The MessageCow
trait is implemented by any
[Message
] as well as any reference to a Message
.
The reason for allowing owned messages is that publishing owned messages can be more efficient in the case of idiomatic messages1.
Hence, when a message will not be needed anymore after publishing, pass it by value. When a message will be needed again after publishing, pass it by reference, instead of cloning and passing by value.
See the [
Message
] trait for an explanation of “idiomatic”. ↩
Sourcepub async fn call_async<'a, R: MessageCow<'a, T::Request>>(
&self,
request: R,
) -> Result<T::Response, RclrsError>where
T: Service,
pub async fn call_async<'a, R: MessageCow<'a, T::Request>>(
&self,
request: R,
) -> Result<T::Response, RclrsError>where
T: Service,
Sends a request and returns the response as a Future
.
The MessageCow
trait is implemented by any
[Message
] as well as any reference to a Message
.
The reason for allowing owned messages is that publishing owned messages can be more efficient in the case of idiomatic messages1.
Hence, when a message will not be needed anymore after publishing, pass it by value. When a message will be needed again after publishing, pass it by reference, instead of cloning and passing by value.
See the [
Message
] trait for an explanation of “idiomatic”. ↩
Sourcepub fn take_response(
&self,
) -> Result<(T::Response, rmw_request_id_t), RclrsError>
pub fn take_response( &self, ) -> Result<(T::Response, rmw_request_id_t), RclrsError>
Fetches a new response.
When there is no new message, this will return a
ClientTakeFailed
.
Sourcepub fn service_is_ready(&self) -> Result<bool, RclrsError>
pub fn service_is_ready(&self) -> Result<bool, RclrsError>
Check if a service server is available.
Will return true if there is a service server available, false if unavailable.
Trait Implementations§
Source§impl<T> ClientBase for Client<T>where
T: Service,
impl<T> ClientBase for Client<T>where
T: Service,
Source§fn handle(&self) -> &ClientHandle
fn handle(&self) -> &ClientHandle
rcl
handle.