Skip to content

Commit

Permalink
Don't return &'static references from functions but give them a gener…
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Sep 1, 2017
1 parent 7bf0140 commit 7a0b380
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gstreamer-audio/src/audio_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl ::AudioFormat {
unsafe { from_glib(ffi::gst_audio_format_from_string(s.to_glib_none().0)) }
}

pub fn to_string(&self) -> &'static str {
pub fn to_string<'a>(&self) -> &'a str {
unsafe {
CStr::from_ptr(ffi::gst_audio_format_to_string(self.to_glib()))
.to_str()
Expand Down
6 changes: 3 additions & 3 deletions gstreamer-audio/src/audio_format_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ impl AudioFormatInfo {
from_glib(self.0.format)
}

pub fn name(&self) -> &'static str {
pub fn name<'a>(&self) -> &'a str {
unsafe { CStr::from_ptr(self.0.name).to_str().unwrap() }
}

pub fn description(&self) -> &'static str {
pub fn description<'a>(&self) -> &'a str {
unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() }
}

Expand All @@ -94,7 +94,7 @@ impl AudioFormatInfo {
from_glib(self.0.unpack_format)
}

pub fn silence(&self) -> &'static [u8] {
pub fn silence<'a>(&self) -> &'a [u8] {
&self.0.silence
}

Expand Down
2 changes: 1 addition & 1 deletion gstreamer-video/src/video_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl ::VideoFormat {
}
}

pub fn to_string(&self) -> &'static str {
pub fn to_string<'a>(&self) -> &'a str {
unsafe {
CStr::from_ptr(ffi::gst_video_format_to_string(self.to_glib()))
.to_str()
Expand Down
4 changes: 2 additions & 2 deletions gstreamer-video/src/video_format_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ impl VideoFormatInfo {
from_glib(self.0.format)
}

pub fn name(&self) -> &'static str {
pub fn name<'a>(&self) -> &'a str {
unsafe { CStr::from_ptr(self.0.name).to_str().unwrap() }
}

pub fn description(&self) -> &'static str {
pub fn description<'a>(&self) -> &'a str {
unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() }
}

Expand Down
4 changes: 2 additions & 2 deletions gstreamer/src/device_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use ffi;
use gobject_ffi;

pub trait DeviceProviderExtManual {
fn get_metadata(&self, key: &str) -> Option<&'static str>;
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>;
}

impl<O: IsA<DeviceProvider>> DeviceProviderExtManual for O {
fn get_metadata(&self, key: &str) -> Option<&'static str> {
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> {
unsafe {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as
*mut ffi::GstDeviceProviderClass;
Expand Down
4 changes: 2 additions & 2 deletions gstreamer/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait ElementExtManual {

fn send_event(&self, event: Event) -> bool;

fn get_metadata(&self, key: &str) -> Option<&'static str>;
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>;

fn get_pad_template(&self, name: &str) -> Option<PadTemplate>;
fn get_pad_template_list(&self) -> Vec<PadTemplate>;
Expand All @@ -79,7 +79,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
}
}

fn get_metadata(&self, key: &str) -> Option<&'static str> {
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> {
unsafe {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as
*mut ffi::GstElementClass;
Expand Down
4 changes: 2 additions & 2 deletions gstreamer/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ use Sample;

pub trait Tag<'a> {
type TagType: FromValueOptional<'a> + SetValue;
fn tag_name() -> &'static str;
fn tag_name<'b>() -> &'b str;
}

macro_rules! impl_tag(
($name:ident, $t:ty, $tag:expr) => {
pub struct $name;
impl<'a> Tag<'a> for $name {
type TagType = $t;
fn tag_name() -> &'static str {
fn tag_name<'b>() -> &'b str {
$tag
}
}
Expand Down

0 comments on commit 7a0b380

Please sign in to comment.