Skip to content

Improve service server ergonomics #373

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

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
Next Next commit
make services FnMut
  • Loading branch information
marcbone committed Mar 19, 2024
commit 13fcc0dc74c7ff484e44d5583539cd11e594b6dc
2 changes: 1 addition & 1 deletion rclrs/src/node.rs
Original file line number Diff line number Diff line change
@@ -270,7 +270,7 @@ impl Node {
) -> Result<Arc<Service<T>>, RclrsError>
where
T: rosidl_runtime_rs::Service,
F: Fn(&rmw_request_id_t, T::Request) -> T::Response + 'static + Send,
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),
4 changes: 2 additions & 2 deletions rclrs/src/service.rs
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ pub trait ServiceBase: Send + Sync {
}

type ServiceCallback<Request, Response> =
Box<dyn Fn(&rmw_request_id_t, Request) -> Response + 'static + Send>;
Box<dyn FnMut(&rmw_request_id_t, Request) -> Response + 'static + Send>;

/// Main class responsible for responding to requests sent by ROS clients.
///
@@ -79,7 +79,7 @@ where
// [`Node::create_service`], see the struct's documentation for the rationale
where
T: rosidl_runtime_rs::Service,
F: Fn(&rmw_request_id_t, T::Request) -> T::Response + 'static + Send,
F: FnMut(&rmw_request_id_t, T::Request) -> T::Response + 'static + Send,
{
// SAFETY: Getting a zero-initialized value is always safe.
let mut rcl_service = unsafe { rcl_get_zero_initialized_service() };