Buffer: serde: add a TODO for a future better design attempt

Serialization and deserialization are asymetrical: ser uses string literals
and de uses a dedicated `struct`, leading to possible inconsistencies.

The idea is to rely on a single `struct` for both ser and de. The only
problem is that, in order to avoid unneeded copies, `buffer` requires an owned
`ByteBuf` for de and a borrowed `Bytes` for ser. `Either` could help adapting
to both situations.
This commit is contained in:
François Laignel 2018-07-29 22:26:52 +02:00 committed by Sebastian Dröge
parent 3ed7257da9
commit 68263ffc7d

View file

@ -16,6 +16,9 @@ use BufferFlags;
use BufferRef;
use ClockTime;
// TODO: try `Either<ByteBuf, Bytes>` to merge the base reprensentations for ser and de
// while avoiding unneeded copy
impl<'a> Serialize for BufferRef {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut buffer = serializer.serialize_struct("Buffer", 6)?;