prost
prost copied to clipboard
Allow using `Box<[u8]>`/`Box<str>` for `bytes`/`string` fields
This reduces the size of objects by one byte each time they're used, which can help quite a lot in some cases.
This is fully optional and the defaults have not changed.
I saw https://github.com/tokio-rs/prost/issues/429 but it's not what I wanted since it asks for two levels of indirection, Arc<Vec<u8>>
for example.
I can probably easily add Arc<str>
and Arc<[u8]>
if necessary though
I tried to implement this in an external lib but it's inefficient if done naively (conversions to String/Vec<u8>
) everywhere and since prost
doesn't expose its helpers to build Message
s, doing it efficiently means copying a lot of code that is intended for internal use only and is quite brittle when used in another crate.
Please merge this, would be extremely helpful.
Rebased to fix conflicts, no actual changes made
It seems like https://github.com/tokio-rs/prost/pull/979 is interesting for this PR. It would simplify the encoding needed for Box<str>
support, am I right?
I'm not working with prost anymore and this PR is way out of date, someone interested can retake it if necessary :)