alsatimer 0.8.0

API binding for alsatimer library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;
use glib::translate::*;

glib::wrapper! {
    /// A boxed object to express event of timer with tick count.
    ///
    /// A [`TickTimeEvent`][crate::TickTimeEvent] includes tick count at which the event is queued.
    ///
    /// The object wraps `struct snd_timer_read` in UAPI of Linux sound subsystem.
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct TickTimeEvent(Boxed<ffi::ALSATimerTickTimeEvent>);

    match fn {
        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::alsatimer_tick_time_event_get_type(), ptr as *mut _) as *mut ffi::ALSATimerTickTimeEvent,
        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::alsatimer_tick_time_event_get_type(), ptr as *mut _),
        type_ => || ffi::alsatimer_tick_time_event_get_type(),
    }
}

impl TickTimeEvent {
    /// Get the tick count since the last event.
    ///
    /// # Returns
    ///
    ///
    /// ## `count`
    /// The tick count since the last event.
    #[doc(alias = "alsatimer_tick_time_event_get_count")]
    #[doc(alias = "get_count")]
    pub fn count(&self) -> u32 {
        unsafe {
            let mut count = std::mem::MaybeUninit::uninit();
            ffi::alsatimer_tick_time_event_get_count(self.to_glib_none().0, count.as_mut_ptr());
            count.assume_init()
        }
    }

    /// Get the resolution of tick event.
    ///
    /// # Returns
    ///
    ///
    /// ## `resolution`
    /// The resolution of tick event.
    #[doc(alias = "alsatimer_tick_time_event_get_resolution")]
    #[doc(alias = "get_resolution")]
    pub fn resolution(&self) -> u32 {
        unsafe {
            let mut resolution = std::mem::MaybeUninit::uninit();
            ffi::alsatimer_tick_time_event_get_resolution(
                self.to_glib_none().0,
                resolution.as_mut_ptr(),
            );
            resolution.assume_init()
        }
    }
}

unsafe impl Send for TickTimeEvent {}