mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-25 16:38:20 +00:00
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:
parent
3ed7257da9
commit
68263ffc7d
1 changed files with 3 additions and 0 deletions
|
@ -16,6 +16,9 @@ use BufferFlags;
|
||||||
use BufferRef;
|
use BufferRef;
|
||||||
use ClockTime;
|
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 {
|
impl<'a> Serialize for BufferRef {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
let mut buffer = serializer.serialize_struct("Buffer", 6)?;
|
let mut buffer = serializer.serialize_struct("Buffer", 6)?;
|
||||||
|
|
Loading…
Reference in a new issue