Skip to content

Commit

Permalink
Fix missing dep when compiling with rosapi, some cleanups from review…
Browse files Browse the repository at this point in the history
…, removed unused import
  • Loading branch information
Carter committed Feb 16, 2024
1 parent 9ce0034 commit 400d9db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 3 additions & 1 deletion roslibrust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ hyper = { version = "0.14", features = [
], optional = true } # Only used with native ros1
gethostname = { version = "0.4", optional = true } # Only used with native ros1
regex = { version = "1.9", optional = true } # Only used with native ros1
# TODO I think we should move rosapi into its own crate...
serde-big-array = { version = "0.5", optional = true } # Only used with rosapi

[dev-dependencies]
env_logger = "0.10"
Expand All @@ -57,7 +59,7 @@ default = []
# Note: all does not include running_bridge as that is only intended for CI
all = []
# Provides a rosapi rust interface
rosapi = []
rosapi = ["serde-big-array"]
# Intended for use with tests, includes tests that rely on a locally running rosbridge
running_bridge = []
# For use with integration tests, indicating we are testing integration with a ros1 bridge
Expand Down
15 changes: 7 additions & 8 deletions roslibrust_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,15 @@ fn generate_field_definition(
quote! {}
}
};
let serde_line = if let Some(Some(fixed_array_length)) = field.field_type.array_info {
if fixed_array_length > 32 {
// This is the largest size of fixed sized array for which macros automatically implement traits
// Until serde supports const generics we need to use serde_big_array for fixed size arrays
// Larger than 32.
const MAX_FIXED_ARRAY_LEN: usize = 32;
let serde_line = match field.field_type.array_info {
Some(Some(fixed_array_len)) if fixed_array_len > MAX_FIXED_ARRAY_LEN => {
quote! { #[serde(with = "::serde_big_array::BigArray")] }
} else {
// Nothing
quote! {}
}
} else {
// Nothing
quote! {}
_ => quote! {},
};
Ok(quote! {
#default_line
Expand Down
2 changes: 1 addition & 1 deletion roslibrust_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ fn parse_ros_files(

#[cfg(test)]
mod test {
use crate::{find_and_generate_ros_messages, FieldInfo};
use crate::find_and_generate_ros_messages;

/// Confirms we don't panic on ros1 parsing
#[test_log::test]
Expand Down

0 comments on commit 400d9db

Please sign in to comment.