Unable to decode a message generated with encode #1317
Unanswered
acolombier
asked this question in
Q&A
Replies: 2 comments
-
|
Looks like I had both misunderstood prost and bytes auto trait for Vec. Here is the working example: #[cfg(test)]
mod tests {
#[test]
fn test_proto() {
let mut buf = Vec::with_capacity(10); // Vec's len will be used as offset so must be 0.
let c = Chunk {
samples_count: 123,
..Default::default()
};
c.encode_length_delimited(&mut buf).unwrap();
let mut reader = buf.as_slice();
let c2 = Chunk::decode_length_delimited(reader).unwrap();
assert_eq!(c, c2);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Actually, it doesn't seem to be working quite as expected, when putting multiple messages. Is this an expected limitation? Should I handle the length limitation explicitly such as: It does feel strange that I would have to "advance" the reader explicitly, is this how this is intended to be used? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am trying to write down message to buffer, so I can read them back later.
Here is my minimal reproducing case
Have I misunderstood how I can use derive? Or am I missing something with the encoder setup?
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions