gstreamer_validate/auto/
runner.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::{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    /// GStreamer Validate Runner class.
17    ///
18    /// Class that manages a Validate test run for some pipeline
19    ///
20    /// ## Properties
21    ///
22    ///
23    /// #### `params`
24    ///  Readable | Writeable | Construct
25    /// <details><summary><h4>Tracer</h4></summary>
26    ///
27    ///
28    /// #### `params`
29    ///  Readable | Writeable | Construct
30    /// </details>
31    /// <details><summary><h4>Object</h4></summary>
32    ///
33    ///
34    /// #### `name`
35    ///  Readable | Writeable | Construct
36    ///
37    ///
38    /// #### `parent`
39    ///  The parent of the object. Please note, that when changing the 'parent'
40    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
41    /// signals due to locking issues. In some cases one can use
42    /// [`element-added`][struct@crate::gst::Bin#element-added] or [`element-removed`][struct@crate::gst::Bin#element-removed] signals on the parent to
43    /// achieve a similar effect.
44    ///
45    /// Readable | Writeable
46    /// </details>
47    ///
48    /// ## Signals
49    ///
50    ///
51    /// #### `report-added`
52    ///
53    ///
54    ///
55    /// #### `stopping`
56    ///
57    /// <details><summary><h4>Object</h4></summary>
58    ///
59    ///
60    /// #### `deep-notify`
61    ///  The deep notify signal is used to be notified of property changes. It is
62    /// typically attached to the toplevel bin to receive notifications from all
63    /// the elements contained in that bin.
64    ///
65    /// Detailed
66    /// </details>
67    ///
68    /// # Implements
69    ///
70    /// [`RunnerExt`][trait@crate::prelude::RunnerExt], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
71    #[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    /// Create a new [`Runner`][crate::Runner]
83    ///
84    /// # Returns
85    ///
86    /// A newly created [`Runner`][crate::Runner]
87    #[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
103mod sealed {
104    pub trait Sealed {}
105    impl<T: super::IsA<super::Runner>> Sealed for T {}
106}
107
108/// Trait containing all [`struct@Runner`] methods.
109///
110/// # Implementors
111///
112/// [`Runner`][struct@crate::Runner]
113pub trait RunnerExt: IsA<Runner> + sealed::Sealed + 'static {
114    #[doc(alias = "gst_validate_runner_add_report")]
115    fn add_report(&self, report: &Report) {
116        unsafe {
117            ffi::gst_validate_runner_add_report(
118                self.as_ref().to_glib_none().0,
119                report.to_glib_none().0,
120            );
121        }
122    }
123
124    #[doc(alias = "gst_validate_runner_exit")]
125    fn exit(&self, print_result: bool) -> i32 {
126        unsafe {
127            ffi::gst_validate_runner_exit(self.as_ref().to_glib_none().0, print_result.into_glib())
128        }
129    }
130
131    #[doc(alias = "gst_validate_runner_get_default_reporting_level")]
132    #[doc(alias = "get_default_reporting_level")]
133    fn default_reporting_level(&self) -> ReportingDetails {
134        unsafe {
135            from_glib(ffi::gst_validate_runner_get_default_reporting_level(
136                self.as_ref().to_glib_none().0,
137            ))
138        }
139    }
140
141    #[doc(alias = "gst_validate_runner_get_reporting_level_for_name")]
142    #[doc(alias = "get_reporting_level_for_name")]
143    fn reporting_level_for_name(&self, name: &str) -> ReportingDetails {
144        unsafe {
145            from_glib(ffi::gst_validate_runner_get_reporting_level_for_name(
146                self.as_ref().to_glib_none().0,
147                name.to_glib_none().0,
148            ))
149        }
150    }
151
152    ///
153    /// # Returns
154    ///
155    /// The list of reports
156    #[doc(alias = "gst_validate_runner_get_reports")]
157    #[doc(alias = "get_reports")]
158    fn reports(&self) -> Vec<Report> {
159        unsafe {
160            FromGlibPtrContainer::from_glib_full(ffi::gst_validate_runner_get_reports(
161                self.as_ref().to_glib_none().0,
162            ))
163        }
164    }
165
166    /// Get the number of reports present in the runner:
167    ///
168    /// # Returns
169    ///
170    /// The number of reports present in the runner.
171    #[doc(alias = "gst_validate_runner_get_reports_count")]
172    #[doc(alias = "get_reports_count")]
173    fn reports_count(&self) -> u32 {
174        unsafe { ffi::gst_validate_runner_get_reports_count(self.as_ref().to_glib_none().0) }
175    }
176
177    /// Prints all the reports on the terminal or on wherever is set
178    /// in the `GST_VALIDATE_FILE` env variable.
179    ///
180    /// # Returns
181    ///
182    /// 0 if no critical error has been found and 18 if a critical
183    /// error has been detected. That return value is usually to be used as
184    /// exit code of the application.
185    #[doc(alias = "gst_validate_runner_printf")]
186    fn printf(&self) -> i32 {
187        unsafe { ffi::gst_validate_runner_printf(self.as_ref().to_glib_none().0) }
188    }
189
190    #[doc(alias = "report-added")]
191    fn connect_report_added<F: Fn(&Self, &Report) + Send + Sync + 'static>(
192        &self,
193        f: F,
194    ) -> SignalHandlerId {
195        unsafe extern "C" fn report_added_trampoline<
196            P: IsA<Runner>,
197            F: Fn(&P, &Report) + Send + Sync + 'static,
198        >(
199            this: *mut ffi::GstValidateRunner,
200            object: *mut ffi::GstValidateReport,
201            f: glib::ffi::gpointer,
202        ) {
203            let f: &F = &*(f as *const F);
204            f(
205                Runner::from_glib_borrow(this).unsafe_cast_ref(),
206                &from_glib_borrow(object),
207            )
208        }
209        unsafe {
210            let f: Box_<F> = Box_::new(f);
211            connect_raw(
212                self.as_ptr() as *mut _,
213                b"report-added\0".as_ptr() as *const _,
214                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
215                    report_added_trampoline::<Self, F> as *const (),
216                )),
217                Box_::into_raw(f),
218            )
219        }
220    }
221
222    #[doc(alias = "stopping")]
223    fn connect_stopping<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
224        unsafe extern "C" fn stopping_trampoline<
225            P: IsA<Runner>,
226            F: Fn(&P) + Send + Sync + 'static,
227        >(
228            this: *mut ffi::GstValidateRunner,
229            f: glib::ffi::gpointer,
230        ) {
231            let f: &F = &*(f as *const F);
232            f(Runner::from_glib_borrow(this).unsafe_cast_ref())
233        }
234        unsafe {
235            let f: Box_<F> = Box_::new(f);
236            connect_raw(
237                self.as_ptr() as *mut _,
238                b"stopping\0".as_ptr() as *const _,
239                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
240                    stopping_trampoline::<Self, F> as *const (),
241                )),
242                Box_::into_raw(f),
243            )
244        }
245    }
246}
247
248impl<O: IsA<Runner>> RunnerExt for O {}