From af27d73e5ce9f03e265aa45d6bcff2dbc4e4d2ee Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 12 Mar 2020 19:17:15 +0100 Subject: [PATCH] gstreamer: Return &'static str from StructureRef The names are backed by Quarks and thus eternally valid. --- gstreamer/src/structure.rs | 12 ++++++------ gstreamer/src/structure_serde.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 4a1d40e9b..fdf2d26dc 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -427,7 +427,7 @@ impl StructureRef { } } - pub fn get_name(&self) -> &str { + pub fn get_name(&self) -> &'static str { unsafe { CStr::from_ptr(gst_sys::gst_structure_get_name(&self.0)) .to_str() @@ -484,7 +484,7 @@ impl StructureRef { Iter::new(self) } - pub fn get_nth_field_name(&self, idx: u32) -> Option<&str> { + pub fn get_nth_field_name(&self, idx: u32) -> Option<&'static str> { unsafe { let field_name = gst_sys::gst_structure_nth_field_name(&self.0, idx); if field_name.is_null() { @@ -625,9 +625,9 @@ impl<'a> FieldIterator<'a> { } impl<'a> Iterator for FieldIterator<'a> { - type Item = &'a str; + type Item = &'static str; - fn next(&mut self) -> Option<&'a str> { + fn next(&mut self) -> Option { if self.idx >= self.n_fields { return None; } @@ -683,9 +683,9 @@ impl<'a> Iter<'a> { } impl<'a> Iterator for Iter<'a> { - type Item = (&'a str, &'a SendValue); + type Item = (&'static str, &'a SendValue); - fn next(&mut self) -> Option<(&'a str, &'a SendValue)> { + fn next(&mut self) -> Option { if let Some(f) = self.iter.next() { let v = self.iter.structure.get_value(f); Some((f, v.unwrap())) diff --git a/gstreamer/src/structure_serde.rs b/gstreamer/src/structure_serde.rs index 654820c26..56ac30322 100644 --- a/gstreamer/src/structure_serde.rs +++ b/gstreamer/src/structure_serde.rs @@ -27,7 +27,7 @@ use value_serde::*; use Structure; use StructureRef; -struct FieldSe<'a>(&'a str, &'a glib::SendValue); +struct FieldSe<'a>(&'static str, &'a glib::SendValue); impl<'a> Serialize for FieldSe<'a> { fn serialize(&self, serializer: S) -> Result { ser_value!(self.1, |type_, value| {