1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// 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 glib::translate::*;
use std::mem;

glib::wrapper! {
    /// A boxed object to express address in ALSA Sequencer.
    ///
    /// A [`Addr`][crate::Addr] is a boxed object to express address in ALSA Sequencer. The address consists
    /// of two parts; the numeric ID of client and port.
    ///
    /// The object wraps `struct snd_seq_addr` in UAPI of Linux sound subsystem.
    #[derive(Debug, PartialOrd, Ord, Hash)]
    pub struct Addr(Boxed<ffi::ALSASeqAddr>);

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

impl Addr {
    /// Allocate and return an instance of [`Addr`][crate::Addr].
    /// ## `client_id`
    /// The numeric ID of client to address.
    /// ## `port_id`
    /// The numeric ID of port to address.
    ///
    /// # Returns
    ///
    /// A [`Addr`][crate::Addr].
    #[doc(alias = "alsaseq_addr_new")]
    pub fn new(client_id: u8, port_id: u8) -> Addr {
        unsafe { from_glib_full(ffi::alsaseq_addr_new(client_id, port_id)) }
    }

    #[doc(alias = "alsaseq_addr_equal")]
    fn equal(&self, target: &Addr) -> bool {
        unsafe {
            from_glib(ffi::alsaseq_addr_equal(
                self.to_glib_none().0,
                target.to_glib_none().0,
            ))
        }
    }

    /// Get the numeric ID of client to address.
    ///
    /// # Returns
    ///
    ///
    /// ## `client_id`
    /// The numeric ID of client to address.
    #[doc(alias = "alsaseq_addr_get_client_id")]
    #[doc(alias = "get_client_id")]
    pub fn client_id(&self) -> u8 {
        unsafe {
            let mut client_id = mem::MaybeUninit::uninit();
            ffi::alsaseq_addr_get_client_id(self.to_glib_none().0, client_id.as_mut_ptr());
            client_id.assume_init()
        }
    }

    /// Get the numeric ID of port to address.
    ///
    /// # Returns
    ///
    ///
    /// ## `port_id`
    /// The numeric ID of port to address.
    #[doc(alias = "alsaseq_addr_get_port_id")]
    #[doc(alias = "get_port_id")]
    pub fn port_id(&self) -> u8 {
        unsafe {
            let mut port_id = mem::MaybeUninit::uninit();
            ffi::alsaseq_addr_get_port_id(self.to_glib_none().0, port_id.as_mut_ptr());
            port_id.assume_init()
        }
    }
}

impl PartialEq for Addr {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.equal(other)
    }
}

impl Eq for Addr {}

unsafe impl Send for Addr {}