duesee / duesee/imap-codec

feat: Zero-copy deserialization

Open
#507 0 comments 1 reaction 0 assignees View on GitHub
chore enhancement
Dominant language
Rust
Stars
52
Forks
25
Avg merge
21h 53m
Merged PRs (30d)
2

Description

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)]`](https://serde.rs/field-attrs.html#borrow) or introducing [`serde_with::BorrowCow`](https://docs.rs/serde_with/latest/serde_with/struct.BorrowCow.html)). 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.