diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index 42c5a36d2..a75ddc861 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -22,12 +22,16 @@ use AppSink; #[allow(clippy::type_complexity)] pub struct AppSinkCallbacks { - eos: Option>>, + eos: Option>>, new_preroll: Option< - RefCell Result + Send + 'static>>, + RefCell< + Box Result + Send + 'static>, + >, >, new_sample: Option< - RefCell Result + Send + 'static>>, + RefCell< + Box Result + Send + 'static>, + >, >, callbacks: gst_app_sys::GstAppSinkCallbacks, } @@ -49,12 +53,16 @@ impl AppSinkCallbacks { #[allow(clippy::type_complexity)] pub struct AppSinkCallbacksBuilder { - eos: Option>>, + eos: Option>>, new_preroll: Option< - RefCell Result + Send + 'static>>, + RefCell< + Box Result + Send + 'static>, + >, >, new_sample: Option< - RefCell Result + Send + 'static>>, + RefCell< + Box Result + Send + 'static>, + >, >, } diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index 6f0ee0bb0..4d4d6d05b 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -17,9 +17,9 @@ use AppSrc; #[allow(clippy::type_complexity)] pub struct AppSrcCallbacks { - need_data: Option>>, - enough_data: Option>, - seek_data: Option bool + Send + Sync + 'static>>, + need_data: Option>>, + enough_data: Option>, + seek_data: Option bool + Send + Sync + 'static>>, callbacks: gst_app_sys::GstAppSrcCallbacks, } @@ -41,9 +41,9 @@ impl AppSrcCallbacks { #[allow(clippy::type_complexity)] pub struct AppSrcCallbacksBuilder { - need_data: Option>>, - enough_data: Option>, - seek_data: Option bool + Send + Sync + 'static>>, + need_data: Option>>, + enough_data: Option>, + seek_data: Option bool + Send + Sync + 'static>>, } impl AppSrcCallbacksBuilder { diff --git a/gstreamer-editing-services/src/timeline_element.rs b/gstreamer-editing-services/src/timeline_element.rs index 3c5778984..7d3cc1aea 100644 --- a/gstreamer-editing-services/src/timeline_element.rs +++ b/gstreamer-editing-services/src/timeline_element.rs @@ -15,7 +15,11 @@ use TimelineElement; pub trait TimelineElementExtManual: 'static { fn get_child_property(&self, name: &str) -> Option; - fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError>; + fn set_child_property( + &self, + name: &str, + value: &dyn glib::ToValue, + ) -> Result<(), glib::BoolError>; } impl> TimelineElementExtManual for O { @@ -41,7 +45,11 @@ impl> TimelineElementExtManual for O { } } - fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError> { + fn set_child_property( + &self, + name: &str, + value: &dyn glib::ToValue, + ) -> Result<(), glib::BoolError> { unsafe { let found: bool = from_glib(ges_sys::ges_timeline_element_lookup_child( self.as_ref().to_glib_none().0, diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index 5fe57bf98..e437e6e08 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -240,7 +240,7 @@ impl error::Error for EncodingProfileBuilderError { "invalid parameters to build encoding profile" } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { None } } diff --git a/gstreamer-rtsp-server/src/rtsp_token.rs b/gstreamer-rtsp-server/src/rtsp_token.rs index 97eb6803d..564a9b095 100644 --- a/gstreamer-rtsp-server/src/rtsp_token.rs +++ b/gstreamer-rtsp-server/src/rtsp_token.rs @@ -21,7 +21,7 @@ impl RTSPToken { unsafe { from_glib_full(gst_rtsp_server_sys::gst_rtsp_token_new_empty()) } } - pub fn new(values: &[(&str, &ToSendValue)]) -> Self { + pub fn new(values: &[(&str, &dyn ToSendValue)]) -> Self { let mut token = RTSPToken::new_empty(); { diff --git a/gstreamer-video/src/video_event.rs b/gstreamer-video/src/video_event.rs index fd89ba27a..4dcd14ba0 100644 --- a/gstreamer-video/src/video_event.rs +++ b/gstreamer-video/src/video_event.rs @@ -40,7 +40,7 @@ macro_rules! event_builder_generic_impl { } } - pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { + pub fn other_fields(self, other_fields: &[(&'a str, &'a dyn ToSendValue)]) -> Self { Self { other_fields: self.other_fields.iter().cloned() .chain(other_fields.iter().cloned()) @@ -84,7 +84,7 @@ pub fn new_downstream_force_key_unit_event<'a>() -> DownstreamForceKeyUnitEventB pub struct DownstreamForceKeyUnitEventBuilder<'a> { seqnum: Option, running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + other_fields: Vec<(&'a str, &'a dyn ToSendValue)>, timestamp: gst::ClockTime, stream_time: gst::ClockTime, running_time: gst::ClockTime, @@ -197,7 +197,7 @@ pub fn new_upstream_force_key_unit_event<'a>() -> UpstreamForceKeyUnitEventBuild pub struct UpstreamForceKeyUnitEventBuilder<'a> { seqnum: Option, running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + other_fields: Vec<(&'a str, &'a dyn ToSendValue)>, running_time: gst::ClockTime, all_headers: bool, count: u32, @@ -299,7 +299,7 @@ pub fn new_still_frame_event<'a>(in_still: bool) -> StillFrameEventBuilder<'a> { pub struct StillFrameEventBuilder<'a> { seqnum: Option, running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + other_fields: Vec<(&'a str, &'a dyn ToSendValue)>, in_still: bool, } diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index d0cf154e9..4101b5661 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -44,7 +44,7 @@ impl Caps { unsafe { from_glib_full(gst_sys::gst_caps_new_any()) } } - pub fn new_simple(name: &str, values: &[(&str, &ToSendValue)]) -> Self { + pub fn new_simple(name: &str, values: &[(&str, &dyn ToSendValue)]) -> Self { assert_initialized_main_thread!(); let mut caps = Caps::new_empty(); @@ -126,7 +126,7 @@ impl fmt::Display for Caps { } impl CapsRef { - pub fn set_simple(&mut self, values: &[(&str, &ToSendValue)]) { + pub fn set_simple(&mut self, values: &[(&str, &dyn ToSendValue)]) { for &(name, value) in values { let value = value.to_value(); diff --git a/gstreamer/src/child_proxy.rs b/gstreamer/src/child_proxy.rs index b12d388f8..a541dcba0 100644 --- a/gstreamer/src/child_proxy.rs +++ b/gstreamer/src/child_proxy.rs @@ -15,7 +15,11 @@ use ChildProxy; pub trait ChildProxyExtManual: 'static { fn get_child_property(&self, name: &str) -> Option; - fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError>; + fn set_child_property( + &self, + name: &str, + value: &dyn glib::ToValue, + ) -> Result<(), glib::BoolError>; } impl> ChildProxyExtManual for O { @@ -41,7 +45,11 @@ impl> ChildProxyExtManual for O { } } - fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError> { + fn set_child_property( + &self, + name: &str, + value: &dyn glib::ToValue, + ) -> Result<(), glib::BoolError> { unsafe { let found: bool = from_glib(gst_sys::gst_child_proxy_lookup( self.as_ref().to_glib_none().0, diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 2c784eecc..616a1fbc9 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -917,7 +917,7 @@ declare_concrete_event!(CustomBothOob); struct EventBuilder<'a> { seqnum: Option, running_time_offset: Option, - other_fields: Vec<(&'a str, &'a ToSendValue)>, + other_fields: Vec<(&'a str, &'a dyn ToSendValue)>, } impl<'a> EventBuilder<'a> { @@ -943,7 +943,7 @@ impl<'a> EventBuilder<'a> { } } - fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { + fn other_fields(self, other_fields: &[(&'a str, &'a dyn ToSendValue)]) -> Self { Self { other_fields: self .other_fields @@ -975,7 +975,7 @@ macro_rules! event_builder_generic_impl { } #[allow(clippy::needless_update)] - pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { + pub fn other_fields(self, other_fields: &[(&'a str, &'a dyn ToSendValue)]) -> Self { Self { builder: self.builder.other_fields(other_fields), .. self diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index 4ca9fd0b5..37c689097 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -91,7 +91,7 @@ where let it = self.to_glib_none().0; mem::forget(self); - let func_box: Box bool + Send + Sync + 'static> = Box::new(func); + let func_box: Box bool + Send + Sync + 'static> = Box::new(func); let mut closure_value = glib::Value::from_type(from_glib(filter_boxed_get_type::())); gobject_sys::g_value_set_boxed( closure_value.to_glib_none_mut().0, @@ -336,7 +336,7 @@ where let func = func as *const gobject_sys::GValue; let func = gobject_sys::g_value_get_boxed(func); #[allow(clippy::transmute_ptr_to_ref)] - let func: &&(Fn(T) -> bool + Send + Sync + 'static) = mem::transmute(func); + let func: &&(dyn Fn(T) -> bool + Send + Sync + 'static) = mem::transmute(func); let value = &*(value as *const glib::Value); let value = value.get::().unwrap(); @@ -349,7 +349,7 @@ where } unsafe extern "C" fn filter_boxed_ref(boxed: gpointer) -> gpointer { - let boxed = Arc::from_raw(boxed as *const (Box bool + Send + Sync + 'static>)); + let boxed = Arc::from_raw(boxed as *const (Box bool + Send + Sync + 'static>)); let copy = Arc::clone(&boxed); // Forget it and keep it alive, we will still need it later @@ -359,7 +359,7 @@ unsafe extern "C" fn filter_boxed_ref(boxed: gpointer) -> gpointer { } unsafe extern "C" fn filter_boxed_unref(boxed: gpointer) { - let _ = Arc::from_raw(boxed as *const (Box bool + Send + Sync + 'static>)); + let _ = Arc::from_raw(boxed as *const (Box bool + Send + Sync + 'static>)); } unsafe extern "C" fn filter_boxed_get_type() -> glib_sys::GType { diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 543ca59a4..f3e5a66ab 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -1192,7 +1192,7 @@ struct MessageBuilder<'a> { src: Option, seqnum: Option, #[allow(unused)] - other_fields: Vec<(&'a str, &'a ToSendValue)>, + other_fields: Vec<(&'a str, &'a dyn ToSendValue)>, } impl<'a> MessageBuilder<'a> { @@ -1222,7 +1222,7 @@ impl<'a> MessageBuilder<'a> { } #[cfg(any(feature = "v1_14", feature = "dox"))] - fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { + fn other_fields(self, other_fields: &[(&'a str, &'a dyn ToSendValue)]) -> Self { Self { other_fields: self .other_fields @@ -1255,7 +1255,7 @@ macro_rules! message_builder_generic_impl { #[cfg(any(feature = "v1_14", feature = "dox"))] #[allow(clippy::needless_update)] - pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { + pub fn other_fields(self, other_fields: &[(&'a str, &'a dyn ToSendValue)]) -> Self { Self { builder: self.builder.other_fields(other_fields), .. self @@ -1746,7 +1746,7 @@ pub struct StreamStatusBuilder<'a> { builder: MessageBuilder<'a>, type_: ::StreamStatusType, owner: &'a ::Element, - status_object: Option<&'a glib::ToSendValue>, + status_object: Option<&'a dyn glib::ToSendValue>, } impl<'a> StreamStatusBuilder<'a> { fn new(type_: ::StreamStatusType, owner: &'a ::Element) -> Self { @@ -1759,7 +1759,7 @@ impl<'a> StreamStatusBuilder<'a> { } } - pub fn status_object(self, status_object: &'a glib::ToSendValue) -> Self { + pub fn status_object(self, status_object: &'a dyn glib::ToSendValue) -> Self { Self { status_object: Some(status_object), ..self @@ -2225,7 +2225,7 @@ impl<'a> DeviceRemovedBuilder<'a> { pub struct PropertyNotifyBuilder<'a> { builder: MessageBuilder<'a>, property_name: &'a str, - value: Option<&'a glib::ToSendValue>, + value: Option<&'a dyn glib::ToSendValue>, } #[cfg(any(feature = "v1_10", feature = "dox"))] impl<'a> PropertyNotifyBuilder<'a> { @@ -2238,7 +2238,7 @@ impl<'a> PropertyNotifyBuilder<'a> { } } - pub fn value(self, value: &'a glib::ToSendValue) -> Self { + pub fn value(self, value: &'a dyn glib::ToSendValue) -> Self { Self { value: Some(value), ..self diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index a447e6307..ee8ca8919 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -933,7 +933,7 @@ impl> PadExtManual for O { user_data: glib_sys::gpointer, ) -> glib_sys::gboolean { let func = - user_data as *mut &mut (FnMut(Event) -> Result, Option>); + user_data as *mut &mut (dyn FnMut(Event) -> Result, Option>); let res = (*func)(from_glib_full(*event)); match res { @@ -958,9 +958,10 @@ impl> PadExtManual for O { unsafe { let mut func = func; - let func_obj: &mut (FnMut(Event) -> Result, Option>) = &mut func; + let func_obj: &mut (dyn FnMut(Event) -> Result, Option>) = + &mut func; let func_ptr = &func_obj - as *const &mut (FnMut(Event) -> Result, Option>) + as *const &mut (dyn FnMut(Event) -> Result, Option>) as glib_sys::gpointer; gst_sys::gst_pad_sticky_events_foreach( diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 83c3a76a6..5e84989f2 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -46,7 +46,7 @@ impl Structure { } } - pub fn new(name: &str, values: &[(&str, &ToSendValue)]) -> Structure { + pub fn new(name: &str, values: &[(&str, &dyn ToSendValue)]) -> Structure { assert_initialized_main_thread!(); let mut structure = Structure::new_empty(name); diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 5829fca31..ae0626292 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -88,9 +88,9 @@ impl<'a> TypeFind<'a> { unsafe impl<'a> Send for TypeFind<'a> {} impl TypeFindFactory { - pub fn call_function(&self, find: &mut TypeFindImpl) { + pub fn call_function(&self, find: &mut dyn TypeFindImpl) { unsafe { - let find_ptr = &find as *const &mut TypeFindImpl as glib_sys::gpointer; + let find_ptr = &find as *const &mut dyn TypeFindImpl as glib_sys::gpointer; let mut find = gst_sys::GstTypeFind { peek: Some(type_find_peek), suggest: Some(type_find_suggest), @@ -119,7 +119,7 @@ unsafe extern "C" fn type_find_closure_drop *const u8 { - let find: &mut &mut TypeFindImpl = &mut *(data as *mut &mut TypeFindImpl); + let find: &mut &mut dyn TypeFindImpl = &mut *(data as *mut &mut dyn TypeFindImpl); match find.peek(offset, size) { None => ptr::null(), Some(data) => data.as_ptr(), @@ -131,14 +131,14 @@ unsafe extern "C" fn type_find_suggest( probability: u32, caps: *mut gst_sys::GstCaps, ) { - let find: &mut &mut TypeFindImpl = &mut *(data as *mut &mut TypeFindImpl); + let find: &mut &mut dyn TypeFindImpl = &mut *(data as *mut &mut dyn TypeFindImpl); find.suggest(from_glib(probability as i32), &from_glib_borrow(caps)); } unsafe extern "C" fn type_find_get_length(data: glib_sys::gpointer) -> u64 { use std::u64; - let find: &mut &mut TypeFindImpl = &mut *(data as *mut &mut TypeFindImpl); + let find: &mut &mut dyn TypeFindImpl = &mut *(data as *mut &mut dyn TypeFindImpl); find.get_length().unwrap_or(u64::MAX) } diff --git a/gstreamer/src/value.rs b/gstreamer/src/value.rs index 349ee295f..c6ee52998 100644 --- a/gstreamer/src/value.rs +++ b/gstreamer/src/value.rs @@ -580,7 +580,7 @@ pub struct Array<'a>(Cow<'a, [glib::SendValue]>); unsafe impl<'a> Send for Array<'a> {} impl<'a> Array<'a> { - pub fn new(values: &[&ToSendValue]) -> Self { + pub fn new(values: &[&dyn ToSendValue]) -> Self { assert_initialized_main_thread!(); Array(values.iter().map(|v| v.to_send_value()).collect()) @@ -601,8 +601,8 @@ impl<'a> Array<'a> { } } -impl<'a> From<&'a [&'a ToSendValue]> for Array<'a> { - fn from(values: &'a [&'a ToSendValue]) -> Self { +impl<'a> From<&'a [&'a dyn ToSendValue]> for Array<'a> { + fn from(values: &'a [&'a dyn ToSendValue]) -> Self { skip_assert_initialized!(); Self::new(values) @@ -658,7 +658,7 @@ pub struct List<'a>(Cow<'a, [glib::SendValue]>); unsafe impl<'a> Send for List<'a> {} impl<'a> List<'a> { - pub fn new(values: &[&ToSendValue]) -> Self { + pub fn new(values: &[&dyn ToSendValue]) -> Self { assert_initialized_main_thread!(); List(values.iter().map(|v| v.to_send_value()).collect()) @@ -679,8 +679,8 @@ impl<'a> List<'a> { } } -impl<'a> From<&'a [&'a ToSendValue]> for List<'a> { - fn from(values: &'a [&'a ToSendValue]) -> Self { +impl<'a> From<&'a [&'a dyn ToSendValue]> for List<'a> { + fn from(values: &'a [&'a dyn ToSendValue]) -> Self { skip_assert_initialized!(); Self::new(values)