I am trying to serialize a struct which stores some data as a Vec<u8>. I am serializing it with postcard and serde.
struct Test {
buf: Vec<u8>,
}
use postcard;
use heapless::Vec;
pub encode() {
let mut bytes = Vec<u8, 1000000>::new();
for i in 0..1000000 {
bytes.push(9);
}
let data = Test { buf: data.to_vec() };
postcard::to_vec::<Test, 1000020>(data).unwrap();
}
I am trying to store about 1MB of data Test.buf, and I am getting fatal runtime error: stack overflow. Since postcard works with heapless::Vec is there a way around it?
Since I am not moving data between embedded systems and can afford to use heap memory. I did cargo add postcard --features use-std. And used postcard::to_stdvec for serialization.