-
Notifications
You must be signed in to change notification settings - Fork 97
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
rust: support encoding borrowed messages #986
Conversation
@john-michaelburke with these changes you can do something like fn test() {
use sbp::codec::{dencode::IterSinkExt, json::JsonEncoder, sbp::SbpEncoder};
let input_file = std::fs::File::open("messages").unwrap();
let log_file = std::fs::File::create("log").unwrap();
let json_log_file = std::fs::File::create("json_log").unwrap();
let mut bin_encoder = SbpEncoder::framed(log_file);
let mut json_encoder = JsonEncoder::framed(json_log_file, serde_json::ser::CompactFormatter);
for msg in iter_messages(input_file) {
let msg = msg.unwrap();
bin_encoder.send(&msg).unwrap();
json_encoder.send(&msg).unwrap();
}
} |
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contingent on re-exporting dencode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this!!
This reverts commit d589967.
needs swift-nav/dencode#2
Makes it so the encoders work with borrowed messages. Adds convenience functions to get a framed writer. Should we reexport dencode so people don't have to bring it in?