From 4abc5c7a48cc2b1312b43326191e92746d466cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 22 Oct 2024 16:12:52 +0300 Subject: [PATCH] Be stricter with Impl-trait bounds to enforce type hierarchies Part-of: --- mux/fmp4/src/fmp4mux/imp.rs | 4 +++- mux/mp4/src/mp4mux/imp.rs | 4 +++- net/hlssink3/src/hlsbasesink.rs | 2 +- net/rtp/src/baseaudiopay/mod.rs | 7 +++++-- net/rtp/src/basedepay/mod.rs | 4 ++-- net/rtp/src/basepay/mod.rs | 4 ++-- net/rtp/src/pcmau/depay/mod.rs | 5 ++++- net/rtp/src/pcmau/pay/mod.rs | 5 ++++- net/webrtc/src/janusvr_signaller/mod.rs | 2 +- net/webrtc/src/signaller/iface.rs | 6 ++++-- net/webrtc/src/webrtcsink/imp.rs | 5 ++++- net/webrtc/src/webrtcsrc/imp.rs | 5 ++++- net/webrtc/src/webrtcsrc/pad.rs | 2 +- 13 files changed, 38 insertions(+), 17 deletions(-) diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs index a4fe4395..98193e51 100644 --- a/mux/fmp4/src/fmp4mux/imp.rs +++ b/mux/fmp4/src/fmp4mux/imp.rs @@ -3957,7 +3957,9 @@ unsafe impl IsSubclassable for super::FMP4Mux { } } -pub(crate) trait FMP4MuxImpl: AggregatorImpl { +pub(crate) trait FMP4MuxImpl: + AggregatorImpl + ObjectSubclass> +{ const VARIANT: super::Variant; } diff --git a/mux/mp4/src/mp4mux/imp.rs b/mux/mp4/src/mp4mux/imp.rs index 7d82f25f..e914a67f 100644 --- a/mux/mp4/src/mp4mux/imp.rs +++ b/mux/mp4/src/mp4mux/imp.rs @@ -1787,7 +1787,9 @@ unsafe impl IsSubclassable for super::MP4Mux { } } -pub(crate) trait MP4MuxImpl: AggregatorImpl { +pub(crate) trait MP4MuxImpl: + AggregatorImpl + ObjectSubclass> +{ const VARIANT: super::Variant; } diff --git a/net/hlssink3/src/hlsbasesink.rs b/net/hlssink3/src/hlsbasesink.rs index ff4e6007..72310f36 100644 --- a/net/hlssink3/src/hlsbasesink.rs +++ b/net/hlssink3/src/hlsbasesink.rs @@ -92,7 +92,7 @@ impl ObjectSubclass for HlsBaseSink { type ParentType = gst::Bin; } -pub trait HlsBaseSinkImpl: BinImpl {} +pub trait HlsBaseSinkImpl: BinImpl + ObjectSubclass> {} unsafe impl IsSubclassable for super::HlsBaseSink {} diff --git a/net/rtp/src/baseaudiopay/mod.rs b/net/rtp/src/baseaudiopay/mod.rs index 75e943dc..46f0908d 100644 --- a/net/rtp/src/baseaudiopay/mod.rs +++ b/net/rtp/src/baseaudiopay/mod.rs @@ -19,7 +19,7 @@ glib::wrapper! { } /// Trait containing extension methods for `RtpBaseAudioPay2`. -pub trait RtpBaseAudioPay2Ext: IsA { +pub trait RtpBaseAudioPay2Ext: IsA + 'static { /// Sets the number of bytes per frame. /// /// Should always be called together with `RtpBasePay2Ext::set_src_caps()`. @@ -31,7 +31,10 @@ pub trait RtpBaseAudioPay2Ext: IsA { impl> RtpBaseAudioPay2Ext for O {} /// Trait to implement in `RtpBaseAudioPay2` subclasses. -pub trait RtpBaseAudioPay2Impl: RtpBasePay2Impl {} +pub trait RtpBaseAudioPay2Impl: + RtpBasePay2Impl + ObjectSubclass> +{ +} unsafe impl IsSubclassable for RtpBaseAudioPay2 { fn class_init(class: &mut glib::Class) { diff --git a/net/rtp/src/basedepay/mod.rs b/net/rtp/src/basedepay/mod.rs index 44856f42..458ec767 100644 --- a/net/rtp/src/basedepay/mod.rs +++ b/net/rtp/src/basedepay/mod.rs @@ -19,7 +19,7 @@ glib::wrapper! { } /// Trait containing extension methods for `RtpBaseDepay2`. -pub trait RtpBaseDepay2Ext: IsA { +pub trait RtpBaseDepay2Ext: IsA + 'static { /// Sends a caps event with the given caps downstream before the next output buffer. fn set_src_caps(&self, src_caps: &gst::Caps) { assert!(src_caps.is_fixed()); @@ -121,7 +121,7 @@ pub trait RtpBaseDepay2Ext: IsA { impl> RtpBaseDepay2Ext for O {} /// Trait to implement in `RtpBaseDepay2` subclasses. -pub trait RtpBaseDepay2Impl: ElementImpl { +pub trait RtpBaseDepay2Impl: ElementImpl + ObjectSubclass> { /// By default only metas without any tags are copied. Adding tags here will also copy the /// metas that *only* have exactly one of these tags. /// diff --git a/net/rtp/src/basepay/mod.rs b/net/rtp/src/basepay/mod.rs index 0732f60a..6a3205ff 100644 --- a/net/rtp/src/basepay/mod.rs +++ b/net/rtp/src/basepay/mod.rs @@ -19,7 +19,7 @@ glib::wrapper! { } /// Trait containing extension methods for `RtpBasePay2`. -pub trait RtpBasePay2Ext: IsA { +pub trait RtpBasePay2Ext: IsA + 'static { /// Sends a caps event with the given caps downstream before the next output buffer. /// /// The caps must be `application/x-rtp` and contain the `clock-rate` field with a suitable @@ -120,7 +120,7 @@ pub trait RtpBasePay2Ext: IsA { impl> RtpBasePay2Ext for O {} /// Trait to implement in `RtpBasePay2` subclasses. -pub trait RtpBasePay2Impl: ElementImpl { +pub trait RtpBasePay2Impl: ElementImpl + ObjectSubclass> { /// Drop buffers with `HEADER` flag. const DROP_HEADER_BUFFERS: bool = false; diff --git a/net/rtp/src/pcmau/depay/mod.rs b/net/rtp/src/pcmau/depay/mod.rs index b56058e3..9aa54b1c 100644 --- a/net/rtp/src/pcmau/depay/mod.rs +++ b/net/rtp/src/pcmau/depay/mod.rs @@ -16,7 +16,10 @@ glib::wrapper! { @extends crate::basedepay::RtpBaseDepay2, gst::Element, gst::Object; } -pub trait RtpPcmauDepayImpl: crate::basedepay::RtpBaseDepay2Impl {} +pub trait RtpPcmauDepayImpl: + crate::basedepay::RtpBaseDepay2Impl + ObjectSubclass> +{ +} unsafe impl IsSubclassable for RtpPcmauDepay { fn class_init(class: &mut glib::Class) { diff --git a/net/rtp/src/pcmau/pay/mod.rs b/net/rtp/src/pcmau/pay/mod.rs index d4097112..7d03f0d9 100644 --- a/net/rtp/src/pcmau/pay/mod.rs +++ b/net/rtp/src/pcmau/pay/mod.rs @@ -16,7 +16,10 @@ glib::wrapper! { @extends crate::baseaudiopay::RtpBaseAudioPay2, crate::basepay::RtpBasePay2, gst::Element, gst::Object; } -pub trait RtpPcmauPayImpl: crate::baseaudiopay::RtpBaseAudioPay2Impl {} +pub trait RtpPcmauPayImpl: + crate::baseaudiopay::RtpBaseAudioPay2Impl + ObjectSubclass> +{ +} unsafe impl IsSubclassable for RtpPcmauPay { fn class_init(class: &mut glib::Class) { diff --git a/net/webrtc/src/janusvr_signaller/mod.rs b/net/webrtc/src/janusvr_signaller/mod.rs index c6cecf94..f4bd28d3 100644 --- a/net/webrtc/src/janusvr_signaller/mod.rs +++ b/net/webrtc/src/janusvr_signaller/mod.rs @@ -10,7 +10,7 @@ glib::wrapper! { pub struct JanusVRSignaller(ObjectSubclass) @implements Signallable; } -trait JanusVRSignallerImpl: ObjectImpl { +trait JanusVRSignallerImpl: ObjectImpl + ObjectSubclass> { fn emit_talking(&self, talking: bool, id: imp::JanusId, audio_level: f32); } diff --git a/net/webrtc/src/signaller/iface.rs b/net/webrtc/src/signaller/iface.rs index 4624f280..6b51f2ba 100644 --- a/net/webrtc/src/signaller/iface.rs +++ b/net/webrtc/src/signaller/iface.rs @@ -535,7 +535,9 @@ where } } -pub trait SignallableImpl: object::ObjectImpl + Send + Sync + 'static { +pub trait SignallableImpl: + ObjectImpl + ObjectSubclass> + Send + Sync + 'static +{ fn start(&self) {} fn stop(&self) {} fn send_sdp(&self, _session_id: &str, _sdp: &gst_webrtc::WebRTCSessionDescription) {} @@ -550,7 +552,7 @@ pub trait SignallableImpl: object::ObjectImpl + Send + Sync + 'static { fn end_session(&self, _session_id: &str) {} } -pub trait SignallableExt: 'static { +pub trait SignallableExt: IsA + 'static { fn start(&self); fn stop(&self); fn munge_sdp( diff --git a/net/webrtc/src/webrtcsink/imp.rs b/net/webrtc/src/webrtcsink/imp.rs index 73fc82eb..40ceea0a 100644 --- a/net/webrtc/src/webrtcsink/imp.rs +++ b/net/webrtc/src/webrtcsink/imp.rs @@ -4314,7 +4314,10 @@ fn register_dye_meta() { unsafe impl IsSubclassable for super::BaseWebRTCSink {} -pub(crate) trait BaseWebRTCSinkImpl: BinImpl {} +pub(crate) trait BaseWebRTCSinkImpl: + BinImpl + ObjectSubclass> +{ +} impl ObjectImpl for BaseWebRTCSink { fn properties() -> &'static [glib::ParamSpec] { diff --git a/net/webrtc/src/webrtcsrc/imp.rs b/net/webrtc/src/webrtcsrc/imp.rs index b8cfda9b..cc5d45fb 100644 --- a/net/webrtc/src/webrtcsrc/imp.rs +++ b/net/webrtc/src/webrtcsrc/imp.rs @@ -64,7 +64,10 @@ unsafe impl IsSubclassable for super::BaseWebRTCSrc { Self::parent_class_init::(class); } } -pub(crate) trait BaseWebRTCSrcImpl: BinImpl {} +pub(crate) trait BaseWebRTCSrcImpl: + BinImpl + ObjectSubclass> +{ +} impl ObjectImpl for BaseWebRTCSrc { fn properties() -> &'static [glib::ParamSpec] { diff --git a/net/webrtc/src/webrtcsrc/pad.rs b/net/webrtc/src/webrtcsrc/pad.rs index b62583a9..f8d10f2a 100644 --- a/net/webrtc/src/webrtcsrc/pad.rs +++ b/net/webrtc/src/webrtcsrc/pad.rs @@ -76,4 +76,4 @@ impl GhostPadImpl for WebRTCSrcPad {} unsafe impl IsSubclassable for super::WebRTCSrcPad {} -pub trait WebRTCSrcPadImpl: GhostPadImpl {} +pub trait WebRTCSrcPadImpl: GhostPadImpl + ObjectSubclass> {}