Commit 68263ffc authored by François Laignel's avatar François Laignel Committed by Sebastian Dröge

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.
parent 3ed7257d
......@@ -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)?;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment