alsatimer/auto/
instance_status.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// A GObject-derived object to express status of user instance.
16    ///
17    /// A [`InstanceStatus`][crate::InstanceStatus] is a GObject-derived object to express status of user instance attached
18    /// to any timer device or the other instance as slave. The call of [`UserInstanceExtManual::status()`][crate::prelude::UserInstanceExtManual::status()]
19    /// returns the instance of object.
20    ///
21    /// The object wraps `struct snd_timer_status` in UAPI of Linux sound subsystem.
22    ///
23    /// ## Properties
24    ///
25    ///
26    /// #### `interval`
27    ///  The current interval in nano second.
28    ///
29    /// Readable
30    ///
31    ///
32    /// #### `lost`
33    ///  The count of losts master ticks.
34    ///
35    /// Readable
36    ///
37    ///
38    /// #### `overrun`
39    ///  The count of overrun in read queue.
40    ///
41    /// Readable
42    ///
43    ///
44    /// #### `queue-size`
45    ///  The current size of queue.
46    ///
47    /// Readable
48    ///
49    /// # Implements
50    ///
51    /// [`InstanceStatusExt`][trait@crate::prelude::InstanceStatusExt], [`InstanceStatusExtManual`][trait@crate::prelude::InstanceStatusExtManual]
52    #[doc(alias = "ALSATimerInstanceStatus")]
53    pub struct InstanceStatus(Object<ffi::ALSATimerInstanceStatus, ffi::ALSATimerInstanceStatusClass>);
54
55    match fn {
56        type_ => || ffi::alsatimer_instance_status_get_type(),
57    }
58}
59
60impl InstanceStatus {
61    pub const NONE: Option<&'static InstanceStatus> = None;
62
63    /// Allocate and return an instance of [`InstanceStatus`][crate::InstanceStatus].
64    ///
65    /// # Returns
66    ///
67    /// A [`InstanceStatus`][crate::InstanceStatus].
68    #[doc(alias = "alsatimer_instance_status_new")]
69    pub fn new() -> InstanceStatus {
70        unsafe { from_glib_full(ffi::alsatimer_instance_status_new()) }
71    }
72}
73
74impl Default for InstanceStatus {
75    fn default() -> Self {
76        Self::new()
77    }
78}
79
80/// Trait containing the part of [`struct@InstanceStatus`] methods.
81///
82/// # Implementors
83///
84/// [`InstanceStatus`][struct@crate::InstanceStatus]
85pub trait InstanceStatusExt: IsA<InstanceStatus> + 'static {
86    /// The current interval in nano second.
87    fn interval(&self) -> u32 {
88        ObjectExt::property(self.as_ref(), "interval")
89    }
90
91    /// The count of losts master ticks.
92    fn lost(&self) -> u32 {
93        ObjectExt::property(self.as_ref(), "lost")
94    }
95
96    /// The count of overrun in read queue.
97    fn overrun(&self) -> u32 {
98        ObjectExt::property(self.as_ref(), "overrun")
99    }
100
101    /// The current size of queue.
102    #[doc(alias = "queue-size")]
103    fn queue_size(&self) -> u32 {
104        ObjectExt::property(self.as_ref(), "queue-size")
105    }
106
107    #[doc(alias = "interval")]
108    fn connect_interval_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
109        unsafe extern "C" fn notify_interval_trampoline<
110            P: IsA<InstanceStatus>,
111            F: Fn(&P) + 'static,
112        >(
113            this: *mut ffi::ALSATimerInstanceStatus,
114            _param_spec: glib::ffi::gpointer,
115            f: glib::ffi::gpointer,
116        ) {
117            let f: &F = &*(f as *const F);
118            f(InstanceStatus::from_glib_borrow(this).unsafe_cast_ref())
119        }
120        unsafe {
121            let f: Box_<F> = Box_::new(f);
122            connect_raw(
123                self.as_ptr() as *mut _,
124                c"notify::interval".as_ptr() as *const _,
125                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
126                    notify_interval_trampoline::<Self, F> as *const (),
127                )),
128                Box_::into_raw(f),
129            )
130        }
131    }
132
133    #[doc(alias = "lost")]
134    fn connect_lost_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
135        unsafe extern "C" fn notify_lost_trampoline<P: IsA<InstanceStatus>, F: Fn(&P) + 'static>(
136            this: *mut ffi::ALSATimerInstanceStatus,
137            _param_spec: glib::ffi::gpointer,
138            f: glib::ffi::gpointer,
139        ) {
140            let f: &F = &*(f as *const F);
141            f(InstanceStatus::from_glib_borrow(this).unsafe_cast_ref())
142        }
143        unsafe {
144            let f: Box_<F> = Box_::new(f);
145            connect_raw(
146                self.as_ptr() as *mut _,
147                c"notify::lost".as_ptr() as *const _,
148                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
149                    notify_lost_trampoline::<Self, F> as *const (),
150                )),
151                Box_::into_raw(f),
152            )
153        }
154    }
155
156    #[doc(alias = "overrun")]
157    fn connect_overrun_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
158        unsafe extern "C" fn notify_overrun_trampoline<
159            P: IsA<InstanceStatus>,
160            F: Fn(&P) + 'static,
161        >(
162            this: *mut ffi::ALSATimerInstanceStatus,
163            _param_spec: glib::ffi::gpointer,
164            f: glib::ffi::gpointer,
165        ) {
166            let f: &F = &*(f as *const F);
167            f(InstanceStatus::from_glib_borrow(this).unsafe_cast_ref())
168        }
169        unsafe {
170            let f: Box_<F> = Box_::new(f);
171            connect_raw(
172                self.as_ptr() as *mut _,
173                c"notify::overrun".as_ptr() as *const _,
174                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
175                    notify_overrun_trampoline::<Self, F> as *const (),
176                )),
177                Box_::into_raw(f),
178            )
179        }
180    }
181
182    #[doc(alias = "queue-size")]
183    fn connect_queue_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
184        unsafe extern "C" fn notify_queue_size_trampoline<
185            P: IsA<InstanceStatus>,
186            F: Fn(&P) + 'static,
187        >(
188            this: *mut ffi::ALSATimerInstanceStatus,
189            _param_spec: glib::ffi::gpointer,
190            f: glib::ffi::gpointer,
191        ) {
192            let f: &F = &*(f as *const F);
193            f(InstanceStatus::from_glib_borrow(this).unsafe_cast_ref())
194        }
195        unsafe {
196            let f: Box_<F> = Box_::new(f);
197            connect_raw(
198                self.as_ptr() as *mut _,
199                c"notify::queue-size".as_ptr() as *const _,
200                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
201                    notify_queue_size_trampoline::<Self, F> as *const (),
202                )),
203                Box_::into_raw(f),
204            )
205        }
206    }
207}
208
209impl<O: IsA<InstanceStatus>> InstanceStatusExt for O {}