Be stricter with Impl-trait bounds to enforce type hierarchies

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1871>
This commit is contained in:
Sebastian Dröge 2024-10-22 16:12:52 +03:00 committed by GStreamer Marge Bot
parent f12bd41510
commit 4abc5c7a48
13 changed files with 38 additions and 17 deletions

View file

@ -3957,7 +3957,9 @@ unsafe impl<T: FMP4MuxImpl> IsSubclassable<T> for super::FMP4Mux {
} }
} }
pub(crate) trait FMP4MuxImpl: AggregatorImpl { pub(crate) trait FMP4MuxImpl:
AggregatorImpl + ObjectSubclass<Type: IsA<super::FMP4Mux>>
{
const VARIANT: super::Variant; const VARIANT: super::Variant;
} }

View file

@ -1787,7 +1787,9 @@ unsafe impl<T: MP4MuxImpl> IsSubclassable<T> for super::MP4Mux {
} }
} }
pub(crate) trait MP4MuxImpl: AggregatorImpl { pub(crate) trait MP4MuxImpl:
AggregatorImpl + ObjectSubclass<Type: IsA<super::MP4Mux>>
{
const VARIANT: super::Variant; const VARIANT: super::Variant;
} }

View file

@ -92,7 +92,7 @@ impl ObjectSubclass for HlsBaseSink {
type ParentType = gst::Bin; type ParentType = gst::Bin;
} }
pub trait HlsBaseSinkImpl: BinImpl {} pub trait HlsBaseSinkImpl: BinImpl + ObjectSubclass<Type: IsA<super::HlsBaseSink>> {}
unsafe impl<T: HlsBaseSinkImpl> IsSubclassable<T> for super::HlsBaseSink {} unsafe impl<T: HlsBaseSinkImpl> IsSubclassable<T> for super::HlsBaseSink {}

View file

@ -19,7 +19,7 @@ glib::wrapper! {
} }
/// Trait containing extension methods for `RtpBaseAudioPay2`. /// Trait containing extension methods for `RtpBaseAudioPay2`.
pub trait RtpBaseAudioPay2Ext: IsA<RtpBaseAudioPay2> { pub trait RtpBaseAudioPay2Ext: IsA<RtpBaseAudioPay2> + 'static {
/// Sets the number of bytes per frame. /// Sets the number of bytes per frame.
/// ///
/// Should always be called together with `RtpBasePay2Ext::set_src_caps()`. /// Should always be called together with `RtpBasePay2Ext::set_src_caps()`.
@ -31,7 +31,10 @@ pub trait RtpBaseAudioPay2Ext: IsA<RtpBaseAudioPay2> {
impl<O: IsA<RtpBaseAudioPay2>> RtpBaseAudioPay2Ext for O {} impl<O: IsA<RtpBaseAudioPay2>> RtpBaseAudioPay2Ext for O {}
/// Trait to implement in `RtpBaseAudioPay2` subclasses. /// Trait to implement in `RtpBaseAudioPay2` subclasses.
pub trait RtpBaseAudioPay2Impl: RtpBasePay2Impl {} pub trait RtpBaseAudioPay2Impl:
RtpBasePay2Impl + ObjectSubclass<Type: IsA<RtpBaseAudioPay2>>
{
}
unsafe impl<T: RtpBaseAudioPay2Impl> IsSubclassable<T> for RtpBaseAudioPay2 { unsafe impl<T: RtpBaseAudioPay2Impl> IsSubclassable<T> for RtpBaseAudioPay2 {
fn class_init(class: &mut glib::Class<Self>) { fn class_init(class: &mut glib::Class<Self>) {

View file

@ -19,7 +19,7 @@ glib::wrapper! {
} }
/// Trait containing extension methods for `RtpBaseDepay2`. /// Trait containing extension methods for `RtpBaseDepay2`.
pub trait RtpBaseDepay2Ext: IsA<RtpBaseDepay2> { pub trait RtpBaseDepay2Ext: IsA<RtpBaseDepay2> + 'static {
/// Sends a caps event with the given caps downstream before the next output buffer. /// Sends a caps event with the given caps downstream before the next output buffer.
fn set_src_caps(&self, src_caps: &gst::Caps) { fn set_src_caps(&self, src_caps: &gst::Caps) {
assert!(src_caps.is_fixed()); assert!(src_caps.is_fixed());
@ -121,7 +121,7 @@ pub trait RtpBaseDepay2Ext: IsA<RtpBaseDepay2> {
impl<O: IsA<RtpBaseDepay2>> RtpBaseDepay2Ext for O {} impl<O: IsA<RtpBaseDepay2>> RtpBaseDepay2Ext for O {}
/// Trait to implement in `RtpBaseDepay2` subclasses. /// Trait to implement in `RtpBaseDepay2` subclasses.
pub trait RtpBaseDepay2Impl: ElementImpl { pub trait RtpBaseDepay2Impl: ElementImpl + ObjectSubclass<Type: IsA<RtpBaseDepay2>> {
/// By default only metas without any tags are copied. Adding tags here will also copy the /// 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. /// metas that *only* have exactly one of these tags.
/// ///

View file

@ -19,7 +19,7 @@ glib::wrapper! {
} }
/// Trait containing extension methods for `RtpBasePay2`. /// Trait containing extension methods for `RtpBasePay2`.
pub trait RtpBasePay2Ext: IsA<RtpBasePay2> { pub trait RtpBasePay2Ext: IsA<RtpBasePay2> + 'static {
/// Sends a caps event with the given caps downstream before the next output buffer. /// 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 /// The caps must be `application/x-rtp` and contain the `clock-rate` field with a suitable
@ -120,7 +120,7 @@ pub trait RtpBasePay2Ext: IsA<RtpBasePay2> {
impl<O: IsA<RtpBasePay2>> RtpBasePay2Ext for O {} impl<O: IsA<RtpBasePay2>> RtpBasePay2Ext for O {}
/// Trait to implement in `RtpBasePay2` subclasses. /// Trait to implement in `RtpBasePay2` subclasses.
pub trait RtpBasePay2Impl: ElementImpl { pub trait RtpBasePay2Impl: ElementImpl + ObjectSubclass<Type: IsA<RtpBasePay2>> {
/// Drop buffers with `HEADER` flag. /// Drop buffers with `HEADER` flag.
const DROP_HEADER_BUFFERS: bool = false; const DROP_HEADER_BUFFERS: bool = false;

View file

@ -16,7 +16,10 @@ glib::wrapper! {
@extends crate::basedepay::RtpBaseDepay2, gst::Element, gst::Object; @extends crate::basedepay::RtpBaseDepay2, gst::Element, gst::Object;
} }
pub trait RtpPcmauDepayImpl: crate::basedepay::RtpBaseDepay2Impl {} pub trait RtpPcmauDepayImpl:
crate::basedepay::RtpBaseDepay2Impl + ObjectSubclass<Type: IsA<RtpPcmauDepay>>
{
}
unsafe impl<T: RtpPcmauDepayImpl> IsSubclassable<T> for RtpPcmauDepay { unsafe impl<T: RtpPcmauDepayImpl> IsSubclassable<T> for RtpPcmauDepay {
fn class_init(class: &mut glib::Class<Self>) { fn class_init(class: &mut glib::Class<Self>) {

View file

@ -16,7 +16,10 @@ glib::wrapper! {
@extends crate::baseaudiopay::RtpBaseAudioPay2, crate::basepay::RtpBasePay2, gst::Element, gst::Object; @extends crate::baseaudiopay::RtpBaseAudioPay2, crate::basepay::RtpBasePay2, gst::Element, gst::Object;
} }
pub trait RtpPcmauPayImpl: crate::baseaudiopay::RtpBaseAudioPay2Impl {} pub trait RtpPcmauPayImpl:
crate::baseaudiopay::RtpBaseAudioPay2Impl + ObjectSubclass<Type: IsA<RtpPcmauPay>>
{
}
unsafe impl<T: RtpPcmauPayImpl> IsSubclassable<T> for RtpPcmauPay { unsafe impl<T: RtpPcmauPayImpl> IsSubclassable<T> for RtpPcmauPay {
fn class_init(class: &mut glib::Class<Self>) { fn class_init(class: &mut glib::Class<Self>) {

View file

@ -10,7 +10,7 @@ glib::wrapper! {
pub struct JanusVRSignaller(ObjectSubclass<imp::Signaller>) @implements Signallable; pub struct JanusVRSignaller(ObjectSubclass<imp::Signaller>) @implements Signallable;
} }
trait JanusVRSignallerImpl: ObjectImpl { trait JanusVRSignallerImpl: ObjectImpl + ObjectSubclass<Type: IsA<JanusVRSignaller>> {
fn emit_talking(&self, talking: bool, id: imp::JanusId, audio_level: f32); fn emit_talking(&self, talking: bool, id: imp::JanusId, audio_level: f32);
} }

View file

@ -535,7 +535,9 @@ where
} }
} }
pub trait SignallableImpl: object::ObjectImpl + Send + Sync + 'static { pub trait SignallableImpl:
ObjectImpl + ObjectSubclass<Type: IsA<super::Signallable>> + Send + Sync + 'static
{
fn start(&self) {} fn start(&self) {}
fn stop(&self) {} fn stop(&self) {}
fn send_sdp(&self, _session_id: &str, _sdp: &gst_webrtc::WebRTCSessionDescription) {} 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) {} fn end_session(&self, _session_id: &str) {}
} }
pub trait SignallableExt: 'static { pub trait SignallableExt: IsA<super::Signallable> + 'static {
fn start(&self); fn start(&self);
fn stop(&self); fn stop(&self);
fn munge_sdp( fn munge_sdp(

View file

@ -4314,7 +4314,10 @@ fn register_dye_meta() {
unsafe impl<T: BaseWebRTCSinkImpl> IsSubclassable<T> for super::BaseWebRTCSink {} unsafe impl<T: BaseWebRTCSinkImpl> IsSubclassable<T> for super::BaseWebRTCSink {}
pub(crate) trait BaseWebRTCSinkImpl: BinImpl {} pub(crate) trait BaseWebRTCSinkImpl:
BinImpl + ObjectSubclass<Type: IsA<super::BaseWebRTCSink>>
{
}
impl ObjectImpl for BaseWebRTCSink { impl ObjectImpl for BaseWebRTCSink {
fn properties() -> &'static [glib::ParamSpec] { fn properties() -> &'static [glib::ParamSpec] {

View file

@ -64,7 +64,10 @@ unsafe impl<T: BaseWebRTCSrcImpl> IsSubclassable<T> for super::BaseWebRTCSrc {
Self::parent_class_init::<T>(class); Self::parent_class_init::<T>(class);
} }
} }
pub(crate) trait BaseWebRTCSrcImpl: BinImpl {} pub(crate) trait BaseWebRTCSrcImpl:
BinImpl + ObjectSubclass<Type: IsA<super::BaseWebRTCSrc>>
{
}
impl ObjectImpl for BaseWebRTCSrc { impl ObjectImpl for BaseWebRTCSrc {
fn properties() -> &'static [glib::ParamSpec] { fn properties() -> &'static [glib::ParamSpec] {

View file

@ -76,4 +76,4 @@ impl GhostPadImpl for WebRTCSrcPad {}
unsafe impl<T: WebRTCSrcPadImpl> IsSubclassable<T> for super::WebRTCSrcPad {} unsafe impl<T: WebRTCSrcPadImpl> IsSubclassable<T> for super::WebRTCSrcPad {}
pub trait WebRTCSrcPadImpl: GhostPadImpl {} pub trait WebRTCSrcPadImpl: GhostPadImpl + ObjectSubclass<Type: IsA<super::WebRTCSrcPad>> {}