Skip to main content

gstreamer/auto/
plugin_feature.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{Object, Plugin, ffi};
7#[cfg(feature = "v1_30")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
9use glib::signal::{SignalHandlerId, connect_raw};
10use glib::{prelude::*, translate::*};
11#[cfg(feature = "v1_30")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GstPluginFeature")]
17    pub struct PluginFeature(Object<ffi::GstPluginFeature, ffi::GstPluginFeatureClass>) @extends Object;
18
19    match fn {
20        type_ => || ffi::gst_plugin_feature_get_type(),
21    }
22}
23
24impl PluginFeature {
25    pub const NONE: Option<&'static PluginFeature> = None;
26}
27
28unsafe impl Send for PluginFeature {}
29unsafe impl Sync for PluginFeature {}
30
31pub trait PluginFeatureExt: IsA<PluginFeature> + 'static {
32    #[doc(alias = "gst_plugin_feature_check_version")]
33    fn check_version(&self, min_major: u32, min_minor: u32, min_micro: u32) -> bool {
34        unsafe {
35            from_glib(ffi::gst_plugin_feature_check_version(
36                self.as_ref().to_glib_none().0,
37                min_major,
38                min_minor,
39                min_micro,
40            ))
41        }
42    }
43
44    #[doc(alias = "gst_plugin_feature_get_plugin")]
45    #[doc(alias = "get_plugin")]
46    fn plugin(&self) -> Option<Plugin> {
47        unsafe {
48            from_glib_full(ffi::gst_plugin_feature_get_plugin(
49                self.as_ref().to_glib_none().0,
50            ))
51        }
52    }
53
54    #[doc(alias = "gst_plugin_feature_get_plugin_name")]
55    #[doc(alias = "get_plugin_name")]
56    fn plugin_name(&self) -> Option<glib::GString> {
57        unsafe {
58            from_glib_none(ffi::gst_plugin_feature_get_plugin_name(
59                self.as_ref().to_glib_none().0,
60            ))
61        }
62    }
63
64    #[cfg(feature = "v1_30")]
65    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
66    #[doc(alias = "rank")]
67    fn connect_rank_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
68        unsafe extern "C" fn notify_rank_trampoline<
69            P: IsA<PluginFeature>,
70            F: Fn(&P) + Send + Sync + 'static,
71        >(
72            this: *mut ffi::GstPluginFeature,
73            _param_spec: glib::ffi::gpointer,
74            f: glib::ffi::gpointer,
75        ) {
76            unsafe {
77                let f: &F = &*(f as *const F);
78                f(PluginFeature::from_glib_borrow(this).unsafe_cast_ref())
79            }
80        }
81        unsafe {
82            let f: Box_<F> = Box_::new(f);
83            connect_raw(
84                self.as_ptr() as *mut _,
85                c"notify::rank".as_ptr(),
86                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
87                    notify_rank_trampoline::<Self, F> as *const (),
88                )),
89                Box_::into_raw(f),
90            )
91        }
92    }
93}
94
95impl<O: IsA<PluginFeature>> PluginFeatureExt for O {}