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    #[doc(alias = "GstValidateRunner")]
17    pub struct Runner(Object<ffi::GstValidateRunner, ffi::GstValidateRunnerClass>) @extends gst::Object;
18
19    match fn {
20        type_ => || ffi::gst_validate_runner_get_type(),
21    }
22}
23
24impl Runner {
25    pub const NONE: Option<&'static Runner> = None;
26
27    #[doc(alias = "gst_validate_runner_new")]
28    pub fn new() -> Runner {
29        assert_initialized_main_thread!();
30        unsafe { from_glib_none(ffi::gst_validate_runner_new()) }
31    }
32}
33
34impl Default for Runner {
35    fn default() -> Self {
36        Self::new()
37    }
38}
39
40unsafe impl Send for Runner {}
41unsafe impl Sync for Runner {}
42
43mod sealed {
44    pub trait Sealed {}
45    impl<T: super::IsA<super::Runner>> Sealed for T {}
46}
47
48pub trait RunnerExt: IsA<Runner> + sealed::Sealed + 'static {
49    #[doc(alias = "gst_validate_runner_add_report")]
50    fn add_report(&self, report: &Report) {
51        unsafe {
52            ffi::gst_validate_runner_add_report(
53                self.as_ref().to_glib_none().0,
54                report.to_glib_none().0,
55            );
56        }
57    }
58
59    #[doc(alias = "gst_validate_runner_exit")]
60    fn exit(&self, print_result: bool) -> i32 {
61        unsafe {
62            ffi::gst_validate_runner_exit(self.as_ref().to_glib_none().0, print_result.into_glib())
63        }
64    }
65
66    #[doc(alias = "gst_validate_runner_get_default_reporting_level")]
67    #[doc(alias = "get_default_reporting_level")]
68    fn default_reporting_level(&self) -> ReportingDetails {
69        unsafe {
70            from_glib(ffi::gst_validate_runner_get_default_reporting_level(
71                self.as_ref().to_glib_none().0,
72            ))
73        }
74    }
75
76    #[doc(alias = "gst_validate_runner_get_reporting_level_for_name")]
77    #[doc(alias = "get_reporting_level_for_name")]
78    fn reporting_level_for_name(&self, name: &str) -> ReportingDetails {
79        unsafe {
80            from_glib(ffi::gst_validate_runner_get_reporting_level_for_name(
81                self.as_ref().to_glib_none().0,
82                name.to_glib_none().0,
83            ))
84        }
85    }
86
87    #[doc(alias = "gst_validate_runner_get_reports")]
88    #[doc(alias = "get_reports")]
89    fn reports(&self) -> Vec<Report> {
90        unsafe {
91            FromGlibPtrContainer::from_glib_full(ffi::gst_validate_runner_get_reports(
92                self.as_ref().to_glib_none().0,
93            ))
94        }
95    }
96
97    #[doc(alias = "gst_validate_runner_get_reports_count")]
98    #[doc(alias = "get_reports_count")]
99    fn reports_count(&self) -> u32 {
100        unsafe { ffi::gst_validate_runner_get_reports_count(self.as_ref().to_glib_none().0) }
101    }
102
103    #[doc(alias = "gst_validate_runner_printf")]
104    fn printf(&self) -> i32 {
105        unsafe { ffi::gst_validate_runner_printf(self.as_ref().to_glib_none().0) }
106    }
107
108    #[doc(alias = "report-added")]
109    fn connect_report_added<F: Fn(&Self, &Report) + Send + Sync + 'static>(
110        &self,
111        f: F,
112    ) -> SignalHandlerId {
113        unsafe extern "C" fn report_added_trampoline<
114            P: IsA<Runner>,
115            F: Fn(&P, &Report) + Send + Sync + 'static,
116        >(
117            this: *mut ffi::GstValidateRunner,
118            object: *mut ffi::GstValidateReport,
119            f: glib::ffi::gpointer,
120        ) {
121            let f: &F = &*(f as *const F);
122            f(
123                Runner::from_glib_borrow(this).unsafe_cast_ref(),
124                &from_glib_borrow(object),
125            )
126        }
127        unsafe {
128            let f: Box_<F> = Box_::new(f);
129            connect_raw(
130                self.as_ptr() as *mut _,
131                b"report-added\0".as_ptr() as *const _,
132                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
133                    report_added_trampoline::<Self, F> as *const (),
134                )),
135                Box_::into_raw(f),
136            )
137        }
138    }
139
140    #[doc(alias = "stopping")]
141    fn connect_stopping<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
142        unsafe extern "C" fn stopping_trampoline<
143            P: IsA<Runner>,
144            F: Fn(&P) + Send + Sync + 'static,
145        >(
146            this: *mut ffi::GstValidateRunner,
147            f: glib::ffi::gpointer,
148        ) {
149            let f: &F = &*(f as *const F);
150            f(Runner::from_glib_borrow(this).unsafe_cast_ref())
151        }
152        unsafe {
153            let f: Box_<F> = Box_::new(f);
154            connect_raw(
155                self.as_ptr() as *mut _,
156                b"stopping\0".as_ptr() as *const _,
157                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
158                    stopping_trampoline::<Self, F> as *const (),
159                )),
160                Box_::into_raw(f),
161            )
162        }
163    }
164}
165
166impl<O: IsA<Runner>> RunnerExt for O {}