Skip to content

Commit ed9a2ee

Browse files
committed
Move ServerGoalHandle to separate module
1 parent dfd9a5f commit ed9a2ee

File tree

2 files changed

+56
-50
lines changed

2 files changed

+56
-50
lines changed

rclrs/src/action.rs

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
mod client;
22
mod server;
3+
mod server_goal_handle;
34

4-
use crate::{rcl_bindings::*, RclrsError};
5-
use std::{marker::PhantomData, sync::Arc};
5+
use crate::rcl_bindings::RCL_ACTION_UUID_SIZE;
66

77
pub use client::{ActionClient, ActionClientBase};
88
pub use server::{ActionServer, ActionServerBase};
9-
10-
// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
11-
// they are running in. Therefore, this type can be safely sent to another thread.
12-
unsafe impl Send for rcl_action_goal_handle_t {}
13-
14-
unsafe impl Sync for rcl_action_goal_handle_t {}
9+
pub use server_goal_handle::ServerGoalHandle;
1510

1611
pub type GoalUUID = [u8; RCL_ACTION_UUID_SIZE];
1712

@@ -25,45 +20,3 @@ pub enum CancelResponse {
2520
Reject = 1,
2621
Accept = 2,
2722
}
28-
29-
pub struct ServerGoalHandle<T>
30-
where
31-
T: rosidl_runtime_rs::Action,
32-
{
33-
rcl_handle: Arc<rcl_action_goal_handle_t>,
34-
goal_request: Arc<T>,
35-
_marker: PhantomData<T>,
36-
}
37-
38-
impl<T> ServerGoalHandle<T>
39-
where
40-
T: rosidl_runtime_rs::Action,
41-
{
42-
pub fn new(rcl_handle: Arc<rcl_action_goal_handle_t>, goal_request: Arc<T>) -> Self {
43-
Self {
44-
rcl_handle,
45-
goal_request: Arc::clone(&goal_request),
46-
_marker: Default::default(),
47-
}
48-
}
49-
50-
pub fn is_canceling(&self) -> bool {
51-
false
52-
}
53-
54-
pub fn is_active(&self) -> bool {
55-
false
56-
}
57-
58-
pub fn is_executing(&self) -> bool {
59-
false
60-
}
61-
62-
pub fn succeed(&self, result: &T::Result) -> Result<(), RclrsError> {
63-
Ok(())
64-
}
65-
66-
pub fn canceled(&self, result: &T::Result) -> Result<(), RclrsError> {
67-
Ok(())
68-
}
69-
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use crate::{rcl_bindings::*, RclrsError};
2+
use std::{
3+
marker::PhantomData,
4+
sync::{Arc, Mutex},
5+
};
6+
7+
// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
8+
// they are running in. Therefore, this type can be safely sent to another thread.
9+
unsafe impl Send for rcl_action_goal_handle_t {}
10+
11+
unsafe impl Sync for rcl_action_goal_handle_t {}
12+
13+
pub struct ServerGoalHandle<T>
14+
where
15+
T: rosidl_runtime_rs::Action,
16+
{
17+
rcl_handle: Arc<Mutex<rcl_action_goal_handle_t>>,
18+
goal_request: Arc<T>,
19+
_marker: PhantomData<T>,
20+
}
21+
22+
impl<T> ServerGoalHandle<T>
23+
where
24+
T: rosidl_runtime_rs::Action,
25+
{
26+
pub fn new(rcl_handle: Arc<Mutex<rcl_action_goal_handle_t>>, goal_request: Arc<T>) -> Self {
27+
Self {
28+
rcl_handle,
29+
goal_request: Arc::clone(&goal_request),
30+
_marker: Default::default(),
31+
}
32+
}
33+
34+
pub fn is_canceling(&self) -> bool {
35+
false
36+
}
37+
38+
pub fn is_active(&self) -> bool {
39+
false
40+
}
41+
42+
pub fn is_executing(&self) -> bool {
43+
false
44+
}
45+
46+
pub fn succeed(&self, result: &T::Result) -> Result<(), RclrsError> {
47+
Ok(())
48+
}
49+
50+
pub fn canceled(&self, result: &T::Result) -> Result<(), RclrsError> {
51+
Ok(())
52+
}
53+
}

0 commit comments

Comments
 (0)