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

Add derive serde attributes to the generated message and service struct #137

Closed
wants to merge 11 commits into from

Conversation

ZhangHanDong
Copy link

@ZhangHanDong ZhangHanDong commented May 29, 2020

hi @adnanademovic ,

thanks very much for your contribution , rosrust is a great crate.

I recently plan to use it in production environment, but I need to return json string directly from the generated struct. But now , rosrust doesn't support this feature, so I implemented it by myself, and test available in the actual environment.

I found that someone else has submitted the PR #135 of similar feature, but his is wrong and can't be compiled.

I hope you can merge and release a new crate version so that my project can use the new version instand of relying on git.

thanks !


usage:

rosrust = { version = "0.9.5",  features = ["derive-serde"]} 

@ZhangHanDong
Copy link
Author

@adnanademovic

rosrust/Cargo.toml Outdated Show resolved Hide resolved
@adnanademovic
Copy link
Owner

Will this cause build failure if you try to serialize a fixed length array longer than 32?
That's the reason the feature isn't already there, due to const generics not existing yet, and thus serde has that limitation.

@ZhangHanDong
Copy link
Author

ZhangHanDong commented Mar 15, 2021

The const generics function will be stable in version 1.51, and this defect may be improved in the future.

I still close the pr first.

@adnanademovic
Copy link
Owner

Yeah once the feature is there, and serde implements it, adding serde support will be extremely simple, and I'd likely add it directly without any feature flags.

@ZhangHanDong
Copy link
Author

ok

@KrasnovPavel
Copy link

@adnanademovic @ZhangHanDong
Hi! It is Rust 1.54 already here. Can you add this feature or serde still doesn't support it?

@adnanademovic
Copy link
Owner

@KrasnovPavel It still doesn't

serde-rs/serde#1937

@adnanademovic
Copy link
Owner

In the meantime, I've added rosrust::Value and rosrust::MessageValue, which do support serde, and are just dynamic representations of ROS messages.

https://github.com/adnanademovic/rosrust/blob/master/rosrust/tests/dynamic_msg.rs#L100-L144

You can do .into() to convert into a Value/MessageValue, or ,try_from() to convert from an arbitrary one.

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

Successfully merging this pull request may close these issues.

4 participants