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, TaskPool, TaskState};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 #[doc(alias = "GstTask")]
11 pub struct Task(Object<ffi::GstTask, ffi::GstTaskClass>) @extends Object;
12
13 match fn {
14 type_ => || ffi::gst_task_get_type(),
15 }
16}
17
18impl Task {
19 pub const NONE: Option<&'static Task> = None;
20
21 #[doc(alias = "gst_task_cleanup_all")]
22 pub fn cleanup_all() {
23 assert_initialized_main_thread!();
24 unsafe {
25 ffi::gst_task_cleanup_all();
26 }
27 }
28}
29
30unsafe impl Send for Task {}
31unsafe impl Sync for Task {}
32
33mod sealed {
34 pub trait Sealed {}
35 impl<T: super::IsA<super::Task>> Sealed for T {}
36}
37
38pub trait TaskExt: IsA<Task> + sealed::Sealed + 'static {
39 #[doc(alias = "gst_task_get_pool")]
40 #[doc(alias = "get_pool")]
41 fn pool(&self) -> TaskPool {
42 unsafe { from_glib_full(ffi::gst_task_get_pool(self.as_ref().to_glib_none().0)) }
43 }
44
45 #[doc(alias = "gst_task_get_state")]
46 #[doc(alias = "get_state")]
47 fn state(&self) -> TaskState {
48 unsafe { from_glib(ffi::gst_task_get_state(self.as_ref().to_glib_none().0)) }
49 }
50
51 #[doc(alias = "gst_task_join")]
52 fn join(&self) -> Result<(), glib::error::BoolError> {
53 unsafe {
54 glib::result_from_gboolean!(
55 ffi::gst_task_join(self.as_ref().to_glib_none().0),
56 "Failed to join task"
57 )
58 }
59 }
60
61 #[doc(alias = "gst_task_pause")]
62 fn pause(&self) -> Result<(), glib::error::BoolError> {
63 unsafe {
64 glib::result_from_gboolean!(
65 ffi::gst_task_pause(self.as_ref().to_glib_none().0),
66 "Failed to pause task"
67 )
68 }
69 }
70
71 #[cfg(feature = "v1_18")]
72 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
73 #[doc(alias = "gst_task_resume")]
74 fn resume(&self) -> Result<(), glib::error::BoolError> {
75 unsafe {
76 glib::result_from_gboolean!(
77 ffi::gst_task_resume(self.as_ref().to_glib_none().0),
78 "Failed to resume task"
79 )
80 }
81 }
82
83 #[doc(alias = "gst_task_set_pool")]
84 fn set_pool(&self, pool: &impl IsA<TaskPool>) {
85 unsafe {
86 ffi::gst_task_set_pool(
87 self.as_ref().to_glib_none().0,
88 pool.as_ref().to_glib_none().0,
89 );
90 }
91 }
92
93 #[doc(alias = "gst_task_set_state")]
94 fn set_state(&self, state: TaskState) -> Result<(), glib::error::BoolError> {
95 unsafe {
96 glib::result_from_gboolean!(
97 ffi::gst_task_set_state(self.as_ref().to_glib_none().0, state.into_glib()),
98 "Failed to set task state"
99 )
100 }
101 }
102
103 #[doc(alias = "gst_task_start")]
104 fn start(&self) -> Result<(), glib::error::BoolError> {
105 unsafe {
106 glib::result_from_gboolean!(
107 ffi::gst_task_start(self.as_ref().to_glib_none().0),
108 "Failed to start task"
109 )
110 }
111 }
112
113 #[doc(alias = "gst_task_stop")]
114 fn stop(&self) -> Result<(), glib::error::BoolError> {
115 unsafe {
116 glib::result_from_gboolean!(
117 ffi::gst_task_stop(self.as_ref().to_glib_none().0),
118 "Failed to stop task"
119 )
120 }
121 }
122}
123
124impl<O: IsA<Task>> TaskExt for O {}
125