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
103/// Trait containing all [`struct@Runner`] methods.
104///
105/// # Implementors
106///
107/// [`Runner`][struct@crate::Runner]
108pub 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    ///
148    /// # Returns
149    ///
150    /// The list of reports
151    #[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    /// Get the number of reports present in the runner:
162    ///
163    /// # Returns
164    ///
165    /// The number of reports present in the runner.
166    #[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    /// Prints all the reports on the terminal or on wherever is set
173    /// in the `GST_VALIDATE_FILE` env variable.
174    ///
175    /// # Returns
176    ///
177    /// 0 if no critical error has been found and 18 if a critical
178    /// error has been detected. That return value is usually to be used as
179    /// exit code of the application.
180    #[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 {}