gstreamer_validate/auto/
runner.rs1use crate::{ffi, Report, ReportingDetails};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GstValidateRunner")]
72    pub struct Runner(Object<ffi::GstValidateRunner, ffi::GstValidateRunnerClass>) @extends gst::Object;
73
74    match fn {
75        type_ => || ffi::gst_validate_runner_get_type(),
76    }
77}
78
79impl Runner {
80    pub const NONE: Option<&'static Runner> = None;
81
82    #[doc(alias = "gst_validate_runner_new")]
88    pub fn new() -> Runner {
89        assert_initialized_main_thread!();
90        unsafe { from_glib_none(ffi::gst_validate_runner_new()) }
91    }
92}
93
94impl Default for Runner {
95    fn default() -> Self {
96        Self::new()
97    }
98}
99
100unsafe impl Send for Runner {}
101unsafe impl Sync for Runner {}
102
103pub trait RunnerExt: IsA<Runner> + 'static {
109    #[doc(alias = "gst_validate_runner_add_report")]
110    fn add_report(&self, report: &Report) {
111        unsafe {
112            ffi::gst_validate_runner_add_report(
113                self.as_ref().to_glib_none().0,
114                report.to_glib_none().0,
115            );
116        }
117    }
118
119    #[doc(alias = "gst_validate_runner_exit")]
120    fn exit(&self, print_result: bool) -> i32 {
121        unsafe {
122            ffi::gst_validate_runner_exit(self.as_ref().to_glib_none().0, print_result.into_glib())
123        }
124    }
125
126    #[doc(alias = "gst_validate_runner_get_default_reporting_level")]
127    #[doc(alias = "get_default_reporting_level")]
128    fn default_reporting_level(&self) -> ReportingDetails {
129        unsafe {
130            from_glib(ffi::gst_validate_runner_get_default_reporting_level(
131                self.as_ref().to_glib_none().0,
132            ))
133        }
134    }
135
136    #[doc(alias = "gst_validate_runner_get_reporting_level_for_name")]
137    #[doc(alias = "get_reporting_level_for_name")]
138    fn reporting_level_for_name(&self, name: &str) -> ReportingDetails {
139        unsafe {
140            from_glib(ffi::gst_validate_runner_get_reporting_level_for_name(
141                self.as_ref().to_glib_none().0,
142                name.to_glib_none().0,
143            ))
144        }
145    }
146
147    #[doc(alias = "gst_validate_runner_get_reports")]
152    #[doc(alias = "get_reports")]
153    fn reports(&self) -> Vec<Report> {
154        unsafe {
155            FromGlibPtrContainer::from_glib_full(ffi::gst_validate_runner_get_reports(
156                self.as_ref().to_glib_none().0,
157            ))
158        }
159    }
160
161    #[doc(alias = "gst_validate_runner_get_reports_count")]
167    #[doc(alias = "get_reports_count")]
168    fn reports_count(&self) -> u32 {
169        unsafe { ffi::gst_validate_runner_get_reports_count(self.as_ref().to_glib_none().0) }
170    }
171
172    #[doc(alias = "gst_validate_runner_printf")]
181    fn printf(&self) -> i32 {
182        unsafe { ffi::gst_validate_runner_printf(self.as_ref().to_glib_none().0) }
183    }
184
185    #[doc(alias = "report-added")]
186    fn connect_report_added<F: Fn(&Self, &Report) + Send + Sync + 'static>(
187        &self,
188        f: F,
189    ) -> SignalHandlerId {
190        unsafe extern "C" fn report_added_trampoline<
191            P: IsA<Runner>,
192            F: Fn(&P, &Report) + Send + Sync + 'static,
193        >(
194            this: *mut ffi::GstValidateRunner,
195            object: *mut ffi::GstValidateReport,
196            f: glib::ffi::gpointer,
197        ) {
198            let f: &F = &*(f as *const F);
199            f(
200                Runner::from_glib_borrow(this).unsafe_cast_ref(),
201                &from_glib_borrow(object),
202            )
203        }
204        unsafe {
205            let f: Box_<F> = Box_::new(f);
206            connect_raw(
207                self.as_ptr() as *mut _,
208                c"report-added".as_ptr() as *const _,
209                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210                    report_added_trampoline::<Self, F> as *const (),
211                )),
212                Box_::into_raw(f),
213            )
214        }
215    }
216
217    #[doc(alias = "stopping")]
218    fn connect_stopping<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
219        unsafe extern "C" fn stopping_trampoline<
220            P: IsA<Runner>,
221            F: Fn(&P) + Send + Sync + 'static,
222        >(
223            this: *mut ffi::GstValidateRunner,
224            f: glib::ffi::gpointer,
225        ) {
226            let f: &F = &*(f as *const F);
227            f(Runner::from_glib_borrow(this).unsafe_cast_ref())
228        }
229        unsafe {
230            let f: Box_<F> = Box_::new(f);
231            connect_raw(
232                self.as_ptr() as *mut _,
233                c"stopping".as_ptr() as *const _,
234                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
235                    stopping_trampoline::<Self, F> as *const (),
236                )),
237                Box_::into_raw(f),
238            )
239        }
240    }
241}
242
243impl<O: IsA<Runner>> RunnerExt for O {}