From 68263ffc7d0c03b96a1b1453a50bad2fe79adc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Sun, 29 Jul 2018 22:26:52 +0200 Subject: [PATCH] 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. --- gstreamer/src/buffer_serde.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gstreamer/src/buffer_serde.rs b/gstreamer/src/buffer_serde.rs index 5dbff9fa7..1b0e096f4 100644 --- a/gstreamer/src/buffer_serde.rs +++ b/gstreamer/src/buffer_serde.rs @@ -16,6 +16,9 @@ use BufferFlags; use BufferRef; use ClockTime; +// TODO: try `Either` to merge the base reprensentations for ser and de +// while avoiding unneeded copy + impl<'a> Serialize for BufferRef { fn serialize(&self, serializer: S) -> Result { let mut buffer = serializer.serialize_struct("Buffer", 6)?;