duesee / imap-codec

Rock-solid and complete codec for IMAP
Apache License 2.0
35 stars 13 forks source link

feat: Zero-copy deserialization #507

Open HenningHolmDE opened 2 weeks ago

HenningHolmDE commented 2 weeks ago

Currently, during deserialization, data is always copied from the deserializer when deserializing into a Cow, which always results in a Cow::Owned, thus copying the data.

There seem to be ways to mitigate this (e.g. using #[serde(borrow)] or introducing serde_with::BorrowCow). When I tried this out briefly, I ended up sprinkling borrow all over the place, not sure, if this is actually required.

Also, adding validation to the deserialization through try_from seems to have complicated things to be less straightforward.

I'm sure there is some good way of doing this optimization.