Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Zeeshan Ali
gstreamer-rs
Commits
23307a47
Commit
23307a47
authored
Jul 17, 2018
by
François Laignel
Committed by
Sebastian Dröge
Jul 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tags: ser/de: gather tags with the same name together
parent
d856fedf
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
298 additions
and
238 deletions
+298
-238
gstreamer/src/structure_serde.rs
gstreamer/src/structure_serde.rs
+4
-1
gstreamer/src/tags.rs
gstreamer/src/tags.rs
+1
-1
gstreamer/src/tags_serde.rs
gstreamer/src/tags_serde.rs
+249
-206
gstreamer/src/toc_serde.rs
gstreamer/src/toc_serde.rs
+16
-8
gstreamer/src/value_serde.rs
gstreamer/src/value_serde.rs
+28
-22
No files found.
gstreamer/src/structure_serde.rs
View file @
23307a47
...
...
@@ -93,7 +93,9 @@ impl<'de> Visitor<'de> for FieldVisitor {
.ok_or
(
de
::
Error
::
custom
(
"Expected a value for `Value` name"
))
?
;
let
type_name
=
seq
.next_element
::
<
String
>
()
?
.ok_or
(
de
::
Error
::
custom
(
"Expected a value for `Value` type"
))
?
;
Ok
(
FieldDe
(
name
,
de_send_value!
(
type_name
,
seq
)))
let
send_value
=
de_send_value!
(
type_name
,
seq
)
?
.ok_or
(
de
::
Error
::
custom
(
"Expected a value for `Value`"
))
?
;
Ok
(
FieldDe
(
name
,
send_value
))
}
}
...
...
@@ -103,6 +105,7 @@ impl<'de> Deserialize<'de> for FieldDe {
}
}
// FIXME: use DeserializeSeed instead
// Use `NamelessStructure` to deserialize the `Field`s and
// to add them to the `Structure` at the same time.
struct
NamelessStructure
(
Structure
);
...
...
gstreamer/src/tags.rs
View file @
23307a47
...
...
@@ -39,7 +39,7 @@ macro_rules! impl_tag(
}
lazy_static!
{
static
ref
$rust_tag
:
&
'static
str
=
pub
static
ref
$rust_tag
:
&
'static
str
=
unsafe
{
CStr
::
from_ptr
(
ffi
::
$gst_tag
)
.to_str
()
.unwrap
()
};
}
};
...
...
gstreamer/src/tags_serde.rs
View file @
23307a47
This diff is collapsed.
Click to expand it.
gstreamer/src/toc_serde.rs
View file @
23307a47
...
...
@@ -199,7 +199,9 @@ mod tests {
"("
,
" scope: Global,"
,
" tags: Some(["
,
" (
\"
title
\"
,
\"
toc
\"
),"
,
" (
\"
title
\"
, ["
,
"
\"
toc
\"
,"
,
" ]),"
,
" ]),"
,
" entries: ["
,
" ("
,
...
...
@@ -221,7 +223,9 @@ mod tests {
" uid:
\"
chapter1.1
\"
,"
,
" start_stop: Some((0, 4)),"
,
" tags: Some(["
,
" (
\"
title
\"
,
\"
chapter 1.1
\"
),"
,
" (
\"
title
\"
, ["
,
"
\"
chapter 1.1
\"
,"
,
" ]),"
,
" ]),"
,
" loop_: Some((None, 0)),"
,
" sub_entries: ["
,
...
...
@@ -232,7 +236,9 @@ mod tests {
" uid:
\"
chapter1.2
\"
,"
,
" start_stop: Some((4, 10)),"
,
" tags: Some(["
,
" (
\"
title
\"
,
\"
chapter 1.2
\"
),"
,
" (
\"
title
\"
, ["
,
"
\"
chapter 1.2
\"
,"
,
" ]),"
,
" ]),"
,
" loop_: Some((None, 0)),"
,
" sub_entries: ["
,
...
...
@@ -245,7 +251,9 @@ mod tests {
" uid:
\"
chapter2
\"
,"
,
" start_stop: Some((10, 15)),"
,
" tags: Some(["
,
" (
\"
title
\"
,
\"
chapter 2
\"
),"
,
" (
\"
title
\"
, ["
,
"
\"
chapter 2
\"
,"
,
" ]),"
,
" ]),"
,
" loop_: Some((None, 0)),"
,
" sub_entries: ["
,
...
...
@@ -271,7 +279,7 @@ mod tests {
(
scope: Global,
tags: Some([
("title", "toc"),
("title",
[
"toc"
]
),
]),
entries: [
(
...
...
@@ -293,7 +301,7 @@ mod tests {
uid: "chapter1.1",
start_stop: Some((0, 4)),
tags: Some([
("title", "chapter 1.1"),
("title",
[
"chapter 1.1"
]
),
]),
loop_: Some((None, 0)),
sub_entries: [
...
...
@@ -304,7 +312,7 @@ mod tests {
uid: "chapter1.2",
start_stop: Some((4, 10)),
tags: Some([
("title", "chapter 1.2"),
("title",
[
"chapter 1.2"
]
),
]),
loop_: Some((None, 0)),
sub_entries: [
...
...
@@ -317,7 +325,7 @@ mod tests {
uid: "chapter2",
start_stop: Some((10, 15)),
tags: Some([
("title", "chapter 2"),
("title",
[
"chapter 2"
]
),
]),
loop_: Some((None, 0)),
sub_entries: [
...
...
gstreamer/src/value_serde.rs
View file @
23307a47
...
...
@@ -163,32 +163,36 @@ impl_ser_send_value_collection!(Array);
impl_ser_send_value_collection!
(
List
);
macro_rules!
de_value
(
(
$outer_type:expr
,
$type_name:expr
,
$seq:expr
,
$t:ty
)
=>
(
$seq
.next_element
::
<
$t
>
()
?
.ok_or_else
(||
de
::
Error
::
custom
(
format!
(
"Expected a value for `{}` with type {:?}"
,
$outer_type
,
$type_name
,
))
)
?
.to_value
()
(
$seq:expr
,
$t:ty
)
=>
(
{
let
value
=
$seq
.next_element
::
<
$t
>
()
?
.and_then
(|
base_value
|
Some
(
base_value
.to_value
()));
Ok
(
value
)
}
);
);
macro_rules!
de_send_value
(
(
$type_name:expr
,
$seq:expr
,
$t:ty
)
=>
(
SendValue
::
from
(
de_value!
(
"Value"
,
$type_name
,
$seq
,
$t
)
.try_into_send_value
::
<
$t
>
()
.map_err
(|
_
|
de
::
Error
::
custom
(
format!
(
"Failed to convert `Value` with type {:?} to `SendValue`"
,
$type_name
,
))
)
?
)
de_send_value!
(
"Value"
,
$type_name
,
$seq
,
$t
)
);
(
$outer_type:expr
,
$type_name:expr
,
$seq:expr
,
$t:ty
)
=>
(
match
de_value!
(
$seq
,
$t
)
?
{
Some
(
value
)
=>
{
let
glib_send_value
=
value
.try_into_send_value
::
<
$t
>
()
.map_err
(|
_
|
de
::
Error
::
custom
(
format!
(
"Failed to convert `{}` with type {:?} to `SendValue`"
,
$outer_type
,
$type_name
,
))
)
?
;
Ok
(
Some
(
SendValue
::
from
(
glib_send_value
)))
}
None
=>
Ok
(
None
)
}
);
(
$type_name:expr
,
$seq:expr
)
=>
(
match
$type_name
.as_str
()
{
...
...
@@ -233,7 +237,9 @@ impl<'de> Visitor<'de> for SendValueVisitor {
fn
visit_seq
<
A
:
SeqAccess
<
'de
>>
(
self
,
mut
seq
:
A
)
->
Result
<
Self
::
Value
,
A
::
Error
>
{
let
type_name
=
seq
.next_element
::
<
String
>
()
?
.ok_or
(
de
::
Error
::
custom
(
"Expected a value for `Value` type"
))
?
;
Ok
(
de_send_value!
(
type_name
,
seq
))
let
send_value
=
de_send_value!
(
type_name
,
seq
)
?
.ok_or
(
de
::
Error
::
custom
(
"Expected a value for `Value`"
))
?
;
Ok
(
send_value
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment