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

Feature request: MinSize #180

Open
elpiel opened this issue Nov 8, 2024 · 3 comments
Open

Feature request: MinSize #180

elpiel opened this issue Nov 8, 2024 · 3 comments

Comments

@elpiel
Copy link

elpiel commented Nov 8, 2024

Apart from the MaxSize experimental feature I'd love to see a MinSize as well.
This can be useful if you want to have a "counter" buffer which keeps track of the maximum number of items that might be able to fit in a given buffer.

E.g. I have a buffer of 4 KiB and I'd like to know what's the maximum number of messages that can fit inside.
This buffer contains embedded_sdmmc::Blocks inside so it's not a continues buffer of bytes and I'm using a second buffer to keep track of how much each block is filled.

@jamesmunns
Copy link
Owner

I somewhat plan to rework MaxSize as part of postcard-schema, as I believe it is possible to calculate this as a const fn. See #179 for an example of this.

One edge case I can think of is how to handle "infinite" cases, as () is serialized as zero bytes on the wire, so your function needs to be careful not to divide by zero :)

@jamesmunns
Copy link
Owner

If you'd like to copy and paste what I did in #179 and switch it to min instead of max, I'd accept that PR.

@elpiel
Copy link
Author

elpiel commented Nov 8, 2024

Hmm that's an interesting case actually heh.
Well I do have a "protocol" level crate although I only (currently) use it with 1 enum that hosts all the messages and it doesn't have a unit type.

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

No branches or pull requests

2 participants