Skip to content

Commit 8b6e825

Browse files
committed
Use usize instead of u8 for domain id
Signed-off-by: Michael X. Grey <[email protected]>
1 parent f2ca13e commit 8b6e825

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

rclrs/src/context.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl Context {
145145
/// It can be set through the `ROS_DOMAIN_ID` environment variable.
146146
///
147147
/// [1]: https://docs.ros.org/en/rolling/Concepts/About-Domain-ID.html
148-
pub fn domain_id(&self) -> u8 {
148+
pub fn domain_id(&self) -> usize {
149149
let mut domain_id: usize = 0;
150150
let ret = unsafe {
151151
rcl_context_get_domain_id(
@@ -155,7 +155,7 @@ impl Context {
155155
};
156156

157157
debug_assert_eq!(ret, 0);
158-
domain_id as u8
158+
domain_id
159159
}
160160

161161
/// Checks if the context is still valid.
@@ -179,7 +179,7 @@ pub struct InitOptions {
179179
/// [ROS_DOMAIN_ID][1] environment variable.
180180
///
181181
/// [1]: https://docs.ros.org/en/rolling/Concepts/Intermediate/About-Domain-ID.html#the-ros-domain-id
182-
domain_id: Option<u8>,
182+
domain_id: Option<usize>,
183183
}
184184

185185
impl InitOptions {
@@ -189,19 +189,19 @@ impl InitOptions {
189189
}
190190

191191
/// Transform an InitOptions into a new one with a certain domain_id
192-
pub fn with_domain_id(mut self, domain_id: Option<u8>) -> InitOptions {
192+
pub fn with_domain_id(mut self, domain_id: Option<usize>) -> InitOptions {
193193
self.domain_id = domain_id;
194194
self
195195
}
196196

197197
/// Set the domain_id of an InitOptions, or reset it to the default behavior
198198
/// (determined by environment variables) by providing None.
199-
pub fn set_domain_id(&mut self, domain_id: Option<u8>) {
199+
pub fn set_domain_id(&mut self, domain_id: Option<usize>) {
200200
self.domain_id = domain_id;
201201
}
202202

203203
/// Get the domain_id that will be provided by these InitOptions.
204-
pub fn domain_id(&self) -> Option<u8> {
204+
pub fn domain_id(&self) -> Option<usize> {
205205
self.domain_id
206206
}
207207

rclrs/src/node/graph.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ mod tests {
462462
let domain_id: usize = std::env::var("ROS_DOMAIN_ID")
463463
.ok()
464464
.and_then(|value| value.parse().ok())
465-
.map(|value| {
465+
.map(|value: usize| {
466466
if value == 99 {
467467
// The default domain ID for this application is 99, which
468468
// conflicts with our arbitrarily chosen default for the
@@ -476,7 +476,8 @@ mod tests {
476476
.unwrap_or(99);
477477

478478
let context =
479-
Context::new_with_options([], InitOptions::new().with_domain_id(Some(domain_id))).unwrap();
479+
Context::new_with_options([], InitOptions::new().with_domain_id(Some(domain_id)))
480+
.unwrap();
480481
let node_name = "test_publisher_names_and_types";
481482
let node = Node::new(&context, node_name).unwrap();
482483
// Test that the graph has no publishers

0 commit comments

Comments
 (0)