Commit graph

14 commits

Author SHA1 Message Date
François Laignel c74eef374a Fix serde for Values with optional Types
Attention: these changes induce breaking changes for the serde
representation of some types.

Serialization of `Value`s used to rely on the `get` function
followed by an `unwrap`. This means that optional types couldn't
be serialized when they were `None`.

This commit distinguishes between the optional `Value` `Types` and
the ones that always return some value.

The `Value`s, `Structure` fields and `Tag`s with following types are
now represented as `Option`s:

- `Buffer`
- `DateTime`
- `Sample` (note: this type is used for `Tag` images)
- `String` (except for `Tag`s - see the comment in `tags_serde.rs`).

The representations for these `Type`s remain unchanged when they are
used in-place (not as part of a `Value`).

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/215
2019-08-19 15:34:24 +02:00
Sebastian Dröge e7898c1b24 Update manual code 2019-04-15 19:19:19 +03:00
François Laignel 9a01bd6202 TagList: handle scope in serde
These changes break compatibility for the serde representations of
`TagList` and `Toc`. Previous representation for the `TagList` was
a sequence. We now have to rely on a struct representation in order
to add `scope`.
2019-03-20 13:58:28 +00:00
Sebastian Dröge 005f436631 Buffer::from_slice() / from_mut_slice() can't possibly return None 2018-12-26 12:13:23 +01:00
Sebastian Dröge 6325e0fcce Fix build with ser_de feature enabled 2018-10-28 17:48:42 +00:00
Sebastian Dröge 9f8ec3b35b Rename TagList::iter_tag_list() to TagList::iter_generic() and ::iter_tag_list_simple() to ::iter()
It's the generic iterator for going over values, and the simple one is
the one you usually want.

Also rename iterator types, but those are internal anyway.
2018-10-28 17:30:25 +00:00
Sebastian Dröge fa29872863 Fix various clippy warnings in the serde code 2018-10-11 11:58:01 +03:00
Sebastian Dröge eb0a804a50 Run everything through latest rustfmt 2018-10-08 15:02:23 +03:00
François Laignel 3ed7257da9 DateTime: serde: use an enum 2018-07-30 23:18:30 +03:00
François Laignel 9fd5392a16 value: serde: use stringify for types 2018-07-30 23:18:30 +03:00
François Laignel 6bda3ef174 serde: add roundtrip tests
This allows making sure serialization and deserialization are in sync for
types with asymetrical implementations.
2018-07-30 23:18:30 +03:00
François Laignel ab9cd29bd6 serde: fmt pass
Note: clippy didn't raise any warning
2018-07-30 23:18:30 +03:00
François Laignel 23307a4795 Tags: ser/de: gather tags with the same name together 2018-07-30 23:18:30 +03:00
François Laignel 90b046fbcf serde: separate serde impl and tests from base module
+ fix erroneous `datetime` instead of `buffer` in `BufferRef::serialize`
+ remove ser/de for `Value`s with types `ULong` & `ILong`
2018-07-30 23:18:30 +03:00