Skip to content

Commit

Permalink
Move location of from_rcl_error to avoid the need for r2r::Error to b…
Browse files Browse the repository at this point in the history
…e Clone
  • Loading branch information
mchhoy committed Dec 13, 2023
1 parent 2e17b8e commit f5ba556
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion r2r/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub type Result<T> = std::result::Result<T, Error>;
/// These values are mostly copied straight from the RCL headers, but
/// some are specific to r2r, such as `GoalCancelRejected` which does
/// not have an analogue in the rcl.
#[derive(Error, Debug, Clone)]
#[derive(Error, Debug)]
pub enum Error {
#[error("RCL_RET_OK")]
RCL_RET_OK,
Expand Down
6 changes: 3 additions & 3 deletions r2r/src/msg_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) fn uuid_msg_to_uuid(msg: &unique_identifier_msgs::msg::UUID) -> uuid:

// TODO where is the best place for this?
thread_local! {
pub static SERIALIZED_MESSAGE_CACHE: Result<RefCell<rcl_serialized_message_t>> = {
pub static SERIALIZED_MESSAGE_CACHE: std::result::Result<RefCell<rcl_serialized_message_t>, i32> = {
use r2r_rcl::*;

let mut msg_buf: rcl_serialized_message_t = unsafe { rcutils_get_zero_initialized_uint8_array() };
Expand All @@ -50,7 +50,7 @@ thread_local! {
};

if ret != RCL_RET_OK as i32 {
Err(Error::from_rcl_error(ret))
Err(ret)
} else {
Ok(RefCell::new(msg_buf))
}
Expand Down Expand Up @@ -94,7 +94,7 @@ pub trait WrappedTypesupport:

SERIALIZED_MESSAGE_CACHE.with(|msg_buf| {

let msg_buf: &mut rcl_serialized_message_t = &mut *msg_buf.as_ref().map_err(|err| err.clone())?.borrow_mut();
let msg_buf: &mut rcl_serialized_message_t = &mut *msg_buf.as_ref().map_err(|err| Error::from_rcl_error(*err))?.borrow_mut();

let result = unsafe {
rmw_serialize(
Expand Down

0 comments on commit f5ba556

Please sign in to comment.