Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve service server ergonomics #373

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove second generic parameter for create_service method
  • Loading branch information
marcbone committed Mar 19, 2024

Verified

This commit was signed with the committer’s verified signature.
CarsonF Carson Full
commit 07bcfe92dd8e991790386b1aa512edd6d7ef5378
2 changes: 1 addition & 1 deletion examples/minimal_client_service/src/minimal_service.rs
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ fn main() -> Result<(), Error> {
let node = rclrs::create_node(&context, "minimal_service")?;

let _server = node
.create_service::<example_interfaces::srv::AddTwoInts, _>("add_two_ints", handle_service)?;
.create_service::<example_interfaces::srv::AddTwoInts>("add_two_ints", handle_service)?;

println!("Starting server");
rclrs::spin(node).map_err(|err| err.into())
5 changes: 2 additions & 3 deletions rclrs/src/node.rs
Original file line number Diff line number Diff line change
@@ -263,14 +263,13 @@ impl Node {
///
/// [1]: crate::Service
// TODO: make service's lifetime depend on node's lifetime
pub fn create_service<T, F>(
pub fn create_service<T>(
&self,
topic: &str,
callback: F,
callback: impl FnMut(&rmw_request_id_t, T::Request) -> T::Response + 'static + Send,
) -> Result<Arc<Service<T>>, RclrsError>
where
T: rosidl_runtime_rs::Service,
F: FnMut(&rmw_request_id_t, T::Request) -> T::Response + 'static + Send,
{
let service = Arc::new(Service::<T>::new(
Arc::clone(&self.rcl_node_mtx),
2 changes: 1 addition & 1 deletion rclrs_tests/src/graph_tests.rs
Original file line number Diff line number Diff line change
@@ -203,7 +203,7 @@ fn test_services() -> Result<(), RclrsError> {
let _node_1_empty_service =
graph
.node1
.create_service::<srv::Empty, _>("graph_test_topic_4", |_, _| srv::Empty_Response {
.create_service::<srv::Empty>("graph_test_topic_4", |_, _| srv::Empty_Response {
structure_needs_at_least_one_member: 0,
})?;
let _node_2_empty_client = graph