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, Class};
use glib::translate::*;

glib::wrapper! {
    /// A boxed object to express the identifier of timer device.
    ///
    /// A [`DeviceId`][crate::DeviceId] is a boxed object to express the identifier of timer device. The
    /// identifier mainly consists of the class of timer device. The other members; the numeric ID of
    /// card, device, and subdevice are optional according to the class of timer device.
    ///
    /// The object wraps `struct snd_timer_id` in UAPI of Linux sound subsystem.
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct DeviceId(Boxed<ffi::ALSATimerDeviceId>);

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

impl DeviceId {
    /// Allocate and return an instance of [`DeviceId`][crate::DeviceId].
    /// ## `class`
    /// The class of device, one of [`Class`][crate::Class].
    /// ## `card_id`
    /// The numeric ID of relevant sound card.
    /// ## `device_id`
    /// The numeric ID of relevant device.
    /// ## `subdevice_id`
    /// The numeric ID of relevant subdevice.
    ///
    /// # Returns
    ///
    /// A [`DeviceId`][crate::DeviceId].
    #[doc(alias = "alsatimer_device_id_new")]
    pub fn new(class: Class, card_id: i32, device_id: i32, subdevice_id: i32) -> DeviceId {
        unsafe {
            from_glib_full(ffi::alsatimer_device_id_new(
                class.into_glib(),
                card_id,
                device_id,
                subdevice_id,
            ))
        }
    }

    /// Get the numeric ID of sound card to which the device belongs.
    ///
    /// # Returns
    ///
    ///
    /// ## `card_id`
    /// The numeric ID of sound card to which the timer belongs.
    #[doc(alias = "alsatimer_device_id_get_card_id")]
    #[doc(alias = "get_card_id")]
    pub fn card_id(&self) -> i32 {
        unsafe {
            let mut card_id = std::mem::MaybeUninit::uninit();
            ffi::alsatimer_device_id_get_card_id(self.to_glib_none().0, card_id.as_mut_ptr());
            card_id.assume_init()
        }
    }

    /// Get the class of timer.
    ///
    /// # Returns
    ///
    ///
    /// ## `class`
    /// The class of timer, one of [`Class`][crate::Class].
    #[doc(alias = "alsatimer_device_id_get_class")]
    #[doc(alias = "get_class")]
    pub fn class(&self) -> Class {
        unsafe {
            let mut class = std::mem::MaybeUninit::uninit();
            ffi::alsatimer_device_id_get_class(self.to_glib_none().0, class.as_mut_ptr());
            from_glib(class.assume_init())
        }
    }

    /// Get the numeric ID of device to which the timer belongs.
    ///
    /// # Returns
    ///
    ///
    /// ## `device_id`
    /// The numeric ID of device to which the timer belongs.
    #[doc(alias = "alsatimer_device_id_get_device_id")]
    #[doc(alias = "get_device_id")]
    pub fn device_id(&self) -> i32 {
        unsafe {
            let mut device_id = std::mem::MaybeUninit::uninit();
            ffi::alsatimer_device_id_get_device_id(self.to_glib_none().0, device_id.as_mut_ptr());
            device_id.assume_init()
        }
    }

    /// Get the numeric ID of subdevice to which the timer belongs.
    ///
    /// # Returns
    ///
    ///
    /// ## `subdevice_id`
    /// The numeric ID of subdevice to which the timer belongs.
    #[doc(alias = "alsatimer_device_id_get_subdevice_id")]
    #[doc(alias = "get_subdevice_id")]
    pub fn subdevice_id(&self) -> i32 {
        unsafe {
            let mut subdevice_id = std::mem::MaybeUninit::uninit();
            ffi::alsatimer_device_id_get_subdevice_id(
                self.to_glib_none().0,
                subdevice_id.as_mut_ptr(),
            );
            subdevice_id.assume_init()
        }
    }
}

unsafe impl Send for DeviceId {}