Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to deserialize fixed size arrays with sizes larger than 32 elements #2

Open
Carter12s opened this issue Feb 8, 2024 · 1 comment

Comments

@Carter12s
Copy link

I'm not sure there is going to be a solution here, but I wanted to check with the authors of this crate if they've come across this problem before and if they have solutions.

I'm struggling / un-able to use this crate to deserialize messages containing fixed sized arrays with more than 32 elements in them. from_slice<> obviously requires that Deserialize is implemented for the type in question, but #[derive(Deserialize)] is only able to produce valid deserialization impls for fixed size arrays of 32 elements or less. Otherwise you get:

error[E0277]: the trait bound `[f64; 33]: Deserialize<'_>` is not satisfied
  --> src/datatests/nav_sat_fix.rs:14:9
   |
14 |         pub r#position_covariance: [f64; 33],
   |         ^^^ the trait `Deserialize<'_>` is not implemented for `[f64; 33]`
   |
   = help: the following other types implement trait `Deserialize<'de>`:
             [T; 0]
             [T; 1]
             [T; 2]

This is particularly challenging because several "standard" ros messages like TwistWithCovariance have fixed sized arrays with 36 members.

I'm assuming someone has already solved this and I'm just being dumb in roslibrust, but not excited about a solution like this: https://stackoverflow.com/questions/62665558/how-can-i-implement-serdedeserialize-for-arrays-larger-than-32

Looking for any guidance.

@Carter12s
Copy link
Author

Note. I ended up finding work around using https://docs.rs/serde-big-array/latest/serde_big_array/

Had to include the "BigArray" serde tag on the message types I was generating, which roslibrust's code generation now supports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant