-
Notifications
You must be signed in to change notification settings - Fork 91
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
pre-compute size of serialized data #46
Comments
Hi, I am trying out postcard as a format for storing data on a SD-card. There will be a large number of data-packages so they will exhaust the number of files allowed on FAT32. embedded-sdmmc does not (yet) support creating directories, so I can't solve it by putting the files in dirs. So now I am considering putting many packages in each file. I will use COBS between the packages, but I need to know the serialized size of the packages. The data-package is a fixed size (no variable length fields): https://github.com/gauteh/sfy/blob/main/sfy-buoy/src/axl.rs#L10 .
Regards, Gaute |
heya, i have a very similar problem and i'm not sure the macros cover the ability to pre-compute size when serializing? (or, i have missed how this can be used to achieve this). i'm looking for something like |
@jamesmunns |
Reopening this, as there are actually a few different things going on here:
I think you are asking for item 2 above @dignifiedquire, do you want to see if that branch works for your needs, and if so you could help get that clean PR opened? |
Oops, forgot my "more below" part: We COULD extend the MAX derive to take attributes on certain items, like: #[derive(Serialize, Deserialize, MaxSize)]
struct Demo<'a> {
arr: [Foo; 5],
#[postcard(max_hint = 128)]
sli: &'a [Bar],
#[postcard(max_hint = 64)]
hst: String
} This covers the |
@jamesmunns just created #86 which should fix things up |
I'm using the slice flavor, I'm wondering if it is possible to compute the size of the serialized data without actually serializing?
The text was updated successfully, but these errors were encountered: