Add 'static trait bound to all ExtManual traits and get rid of trait bounds for their impls

This commit is contained in:
Sebastian Dröge 2018-12-08 11:22:42 +02:00
parent 5c93e134a7
commit 6bba3d8518
26 changed files with 34 additions and 36 deletions

View file

@ -14,7 +14,7 @@ use Aggregator;
use std::ops; use std::ops;
pub trait AggregatorExtManual { pub trait AggregatorExtManual: 'static {
fn finish_buffer(&self, buffer: gst::Buffer) -> gst::FlowReturn; fn finish_buffer(&self, buffer: gst::Buffer) -> gst::FlowReturn;
} }

View file

@ -15,7 +15,7 @@ use AggregatorPad;
use std::ops; use std::ops;
pub trait AggregatorPadExtManual { pub trait AggregatorPadExtManual: 'static {
fn get_segment(&self) -> gst::Segment; fn get_segment(&self) -> gst::Segment;
} }

View file

@ -13,7 +13,7 @@ use gst;
use std::ops; use std::ops;
use BaseSink; use BaseSink;
pub trait BaseSinkExtManual { pub trait BaseSinkExtManual: 'static {
fn get_segment(&self) -> gst::Segment; fn get_segment(&self) -> gst::Segment;
} }

View file

@ -13,7 +13,7 @@ use gst;
use std::ops; use std::ops;
use BaseSrc; use BaseSrc;
pub trait BaseSrcExtManual { pub trait BaseSrcExtManual: 'static {
fn get_segment(&self) -> gst::Segment; fn get_segment(&self) -> gst::Segment;
} }

View file

@ -13,7 +13,7 @@ use gst;
use std::ops; use std::ops;
use BaseTransform; use BaseTransform;
pub trait BaseTransformExtManual { pub trait BaseTransformExtManual: 'static {
fn get_segment(&self) -> gst::Segment; fn get_segment(&self) -> gst::Segment;
} }

View file

@ -13,7 +13,7 @@ use glib::translate::*;
use std::ptr; use std::ptr;
use TimelineElement; use TimelineElement;
pub trait TimelineElementExtManual { pub trait TimelineElementExtManual: 'static {
fn get_child_property(&self, name: &str) -> Option<glib::Value>; fn get_child_property(&self, name: &str) -> Option<glib::Value>;
fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError>; fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError>;
} }

View file

@ -31,7 +31,7 @@ impl GLContext {
} }
} }
pub trait GLContextExtManual { pub trait GLContextExtManual: 'static {
fn get_gl_context(&self) -> uintptr_t; fn get_gl_context(&self) -> uintptr_t;
fn get_proc_address(&self, name: &str) -> uintptr_t; fn get_proc_address(&self, name: &str) -> uintptr_t;

View file

@ -6,7 +6,7 @@ use RTSPAddress;
use RTSPAddressPool; use RTSPAddressPool;
use RTSPAddressPoolResult; use RTSPAddressPoolResult;
pub trait RTSPAddressPoolExtManual { pub trait RTSPAddressPoolExtManual: 'static {
fn reserve_address( fn reserve_address(
&self, &self,
ip_address: &str, ip_address: &str,

View file

@ -4,7 +4,7 @@ use glib::translate::*;
use RTSPAuth; use RTSPAuth;
use RTSPToken; use RTSPToken;
pub trait RTSPAuthExtManual { pub trait RTSPAuthExtManual: 'static {
fn set_default_token<'a, P: Into<Option<&'a mut RTSPToken>>>(&self, token: P); fn set_default_token<'a, P: Into<Option<&'a mut RTSPToken>>>(&self, token: P);
} }

View file

@ -5,7 +5,7 @@ use glib::source::SourceId;
use glib::translate::*; use glib::translate::*;
use RTSPClient; use RTSPClient;
pub trait RTSPClientExtManual { pub trait RTSPClientExtManual: 'static {
fn attach<'a, P: Into<Option<&'a glib::MainContext>>>(&self, context: P) -> SourceId; fn attach<'a, P: Into<Option<&'a glib::MainContext>>>(&self, context: P) -> SourceId;
} }

View file

@ -14,7 +14,7 @@ use glib::IsA;
#[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg(any(feature = "v1_14", feature = "dox"))]
use gst; use gst;
pub trait RTSPMediaFactoryExtManual { pub trait RTSPMediaFactoryExtManual: 'static {
#[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg(any(feature = "v1_14", feature = "dox"))]
fn add_role_from_structure(&self, structure: &gst::StructureRef); fn add_role_from_structure(&self, structure: &gst::StructureRef);
} }

View file

@ -5,7 +5,7 @@ use glib::source::SourceId;
use glib::translate::*; use glib::translate::*;
use RTSPServer; use RTSPServer;
pub trait RTSPServerExtManual { pub trait RTSPServerExtManual: 'static {
fn attach<'a, P: Into<Option<&'a glib::MainContext>>>(&self, context: P) -> SourceId; fn attach<'a, P: Into<Option<&'a glib::MainContext>>>(&self, context: P) -> SourceId;
} }

View file

@ -31,7 +31,7 @@ fn into_raw_watch<F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static>(func:
Box::into_raw(func) as gpointer Box::into_raw(func) as gpointer
} }
pub trait RTSPSessionPoolExtManual { pub trait RTSPSessionPoolExtManual: 'static {
fn create_watch<'a, N: Into<Option<&'a str>>, F>( fn create_watch<'a, N: Into<Option<&'a str>>, F>(
&self, &self,
name: N, name: N,

View file

@ -15,7 +15,7 @@ use VideoOverlay;
use glib::IsA; use glib::IsA;
pub trait VideoOverlayExtManual { pub trait VideoOverlayExtManual: 'static {
unsafe fn set_window_handle(&self, handle: uintptr_t); unsafe fn set_window_handle(&self, handle: uintptr_t);
unsafe fn got_window_handle(&self, handle: uintptr_t); unsafe fn got_window_handle(&self, handle: uintptr_t);
} }

View file

@ -18,7 +18,7 @@ use ffi;
use std::ops; use std::ops;
use std::path; use std::path;
pub trait GstBinExtManual { pub trait GstBinExtManual: 'static {
fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError>; fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError>;
fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError>; fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError>;

View file

@ -225,7 +225,7 @@ impl Default for BufferPool {
} }
} }
pub trait BufferPoolExtManual { pub trait BufferPoolExtManual: 'static {
fn get_config(&self) -> BufferPoolConfig; fn get_config(&self) -> BufferPoolConfig;
fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError>; fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError>;

View file

@ -27,7 +27,7 @@ cfg_if! {
use super::Bus; use super::Bus;
pub trait UnixBusExtManual { pub trait UnixBusExtManual: 'static {
fn get_pollfd(&self) -> unix::io::RawFd; fn get_pollfd(&self) -> unix::io::RawFd;
} }

View file

@ -27,7 +27,7 @@ cfg_if! {
use super::Bus; use super::Bus;
pub trait WindowsBusExtManual { pub trait WindowsBusExtManual: 'static {
fn get_pollfd(&self) -> windows::io::RawHandle; fn get_pollfd(&self) -> windows::io::RawHandle;
} }

View file

@ -13,7 +13,7 @@ use glib::translate::*;
use std::ptr; use std::ptr;
use ChildProxy; use ChildProxy;
pub trait ChildProxyExtManual { pub trait ChildProxyExtManual: 'static {
fn get_child_property(&self, name: &str) -> Option<glib::Value>; fn get_child_property(&self, name: &str) -> Option<glib::Value>;
fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError>; fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError>;
} }

View file

@ -163,7 +163,7 @@ impl Clock {
} }
} }
pub trait ClockExtManual { pub trait ClockExtManual: 'static {
fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> Option<ClockId>; fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> Option<ClockId>;
fn periodic_id_reinit( fn periodic_id_reinit(
@ -178,7 +178,7 @@ pub trait ClockExtManual {
fn single_shot_id_reinit(&self, id: &ClockId, time: ClockTime) -> Result<(), glib::BoolError>; fn single_shot_id_reinit(&self, id: &ClockId, time: ClockTime) -> Result<(), glib::BoolError>;
} }
impl<O: IsA<Clock> + IsA<glib::object::Object>> ClockExtManual for O { impl<O: IsA<Clock>> ClockExtManual for O {
fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> Option<ClockId> { fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> Option<ClockId> {
unsafe { unsafe {
from_glib_full(ffi::gst_clock_new_periodic_id( from_glib_full(ffi::gst_clock_new_periodic_id(

View file

@ -16,7 +16,7 @@ use std::ffi::CStr;
use ffi; use ffi;
use gobject_ffi; use gobject_ffi;
pub trait DeviceProviderExtManual { pub trait DeviceProviderExtManual: 'static {
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>; fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>;
} }

View file

@ -92,7 +92,7 @@ impl FromGlib<libc::c_ulong> for NotifyWatchId {
} }
} }
pub trait ElementExtManual { pub trait ElementExtManual: 'static {
fn get_element_class(&self) -> &ElementClass; fn get_element_class(&self) -> &ElementClass;
fn query(&self, query: &mut QueryRef) -> bool; fn query(&self, query: &mut QueryRef) -> bool;

View file

@ -4,7 +4,7 @@ use glib::IsA;
use ffi; use ffi;
pub trait GObjectExtManualGst { pub trait GObjectExtManualGst: 'static {
fn set_property_from_str(&self, name: &str, value: &str); fn set_property_from_str(&self, name: &str, value: &str);
} }

View file

@ -9,12 +9,12 @@
use glib; use glib;
use glib::object::{Downcast, ObjectExt}; use glib::object::{Downcast, ObjectExt};
use glib::signal::SignalHandlerId; use glib::signal::SignalHandlerId;
use glib::translate::{from_glib_none, ToGlibPtr}; use glib::translate::{from_glib_borrow, from_glib_none, ToGlibPtr};
use glib::IsA; use glib::IsA;
use gobject_ffi; use gobject_ffi;
pub trait GstObjectExtManual { pub trait GstObjectExtManual: 'static {
fn connect_deep_notify< fn connect_deep_notify<
'a, 'a,
P: Into<Option<&'a str>>, P: Into<Option<&'a str>>,
@ -26,7 +26,7 @@ pub trait GstObjectExtManual {
) -> SignalHandlerId; ) -> SignalHandlerId;
} }
impl<O: IsA<::Object> + IsA<glib::Object> + glib::value::SetValue> GstObjectExtManual for O { impl<O: IsA<::Object>> GstObjectExtManual for O {
fn connect_deep_notify< fn connect_deep_notify<
'a, 'a,
P: Into<Option<&'a str>>, P: Into<Option<&'a str>>,
@ -43,13 +43,11 @@ impl<O: IsA<::Object> + IsA<glib::Object> + glib::value::SetValue> GstObjectExtM
"deep-notify".into() "deep-notify".into()
}; };
self.connect(signal_name.as_str(), false, move |values| { let obj: glib::Object =
let obj: O = unsafe { unsafe { from_glib_borrow(self.to_glib_none().0 as *mut gobject_ffi::GObject) };
values[0]
.get::<glib::Object>() obj.connect(signal_name.as_str(), false, move |values| {
.unwrap() let obj: O = unsafe { values[0].get::<::Object>().unwrap().downcast_unchecked() };
.downcast_unchecked()
};
let prop_obj: ::Object = values[1].get().unwrap(); let prop_obj: ::Object = values[1].get().unwrap();
let pspec = unsafe { let pspec = unsafe {

View file

@ -105,7 +105,7 @@ impl Drop for StreamLock {
} }
} }
pub trait PadExtManual { pub trait PadExtManual: 'static {
fn add_probe<F>(&self, mask: PadProbeType, func: F) -> Option<PadProbeId> fn add_probe<F>(&self, mask: PadProbeType, func: F) -> Option<PadProbeId>
where where
F: Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static; F: Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static;

View file

@ -14,7 +14,7 @@ use tags::*;
use TagMergeMode; use TagMergeMode;
use TagSetter; use TagSetter;
pub trait TagSetterExtManual { pub trait TagSetterExtManual: 'static {
fn add<'a, T: Tag<'a>>(&self, value: T::TagType, mode: TagMergeMode) fn add<'a, T: Tag<'a>>(&self, value: T::TagType, mode: TagMergeMode)
where where
T::TagType: ToSendValue; T::TagType: ToSendValue;