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.
Currently, during deserialization, data is always copied from the deserializer when deserializing into a
Cow
, which always results in aCow::Owned
, thus copying the data.There seem to be ways to mitigate this (e.g. using
#[serde(borrow)]
or introducingserde_with::BorrowCow
). When I tried this out briefly, I ended up sprinklingborrow
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.