jamesmunns / postcard

A no_std + serde compatible message library for Rust
Apache License 2.0
874 stars 87 forks source link

Can the `to_allocvec` function ever return an Err? #132

Open mitchmindtree opened 6 months ago

mitchmindtree commented 6 months ago

I noticed that the to_allocvec function returns a Result, but I'm curious under what cases it can actually produce an error? It looks like the Flavour implementation cannot fail, and the only serialization-related error variants are related to OOM which I don't think AllocVec's Flavour implementation attempts to catch.

Is including a Result in the return type more for backwards-compatibility in case the implementation changes in the future?

Also, thanks for your work on postcard!

Edit: I guess there's always the possibility that a Serialize implementation produces a custom error, but I'm more curious if there are any known possible failure cases with the standard types and regular derive implementations :thinking: