Skip to content

Commit

Permalink
Replace set_result_response_status with create_result_response
Browse files Browse the repository at this point in the history
rclrs needs to be able to generically construct result responses,
including the user-defined result field.
  • Loading branch information
nwn committed Sep 28, 2024
1 parent 6d7021a commit 7a39794
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions rosidl_generator_rs/resource/action.rs.em
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ impl rosidl_runtime_rs::ActionImpl for @(type_name) {
request.goal_id.uuid
}

fn set_result_response_status(response: &mut <<Self::GetResultService as rosidl_runtime_rs::Service>::Response as rosidl_runtime_rs::Message>::RmwMsg, status: i8) {
response.status = status;
fn create_result_response(status: i8, result: <<Self as Action>::Result as Message>::RmwMsg) -> <<Self::GetResultService as Service>::Response as Message>::RmwMsg {
<<Self::GetResultService as rosidl_runtime_rs::Service>::Response as rosidl_runtime_rs::Message>::RmwMsg {
status,
result,
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions rosidl_runtime_rs/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,6 @@ pub trait ActionImpl: 'static + Action {
/// Get the UUID of a result request.
fn get_result_request_uuid(request: &<<Self::GetResultService as Service>::Request as Message>::RmwMsg) -> [u8; 16];

/// Sets the `status` field of a result response.
fn set_result_response_status(response: &mut <<Self::GetResultService as Service>::Response as Message>::RmwMsg, status: i8);
/// Create a result response message with the given status and contents.
fn create_result_response(status: i8, result: <<Self as Action>::Result as Message>::RmwMsg) -> <<Self::GetResultService as Service>::Response as Message>::RmwMsg;
}

0 comments on commit 7a39794

Please sign in to comment.