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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::translate::*;

glib::wrapper! {
    #[derive(Debug, PartialOrd, Ord, Hash)]
    pub struct DmabufFormats(Shared<ffi::GdkDmabufFormats>);

    match fn {
        ref => |ptr| ffi::gdk_dmabuf_formats_ref(ptr),
        unref => |ptr| ffi::gdk_dmabuf_formats_unref(ptr),
        type_ => || ffi::gdk_dmabuf_formats_get_type(),
    }
}

impl DmabufFormats {
    #[doc(alias = "gdk_dmabuf_formats_contains")]
    pub fn contains(&self, fourcc: u32, modifier: u64) -> bool {
        unsafe {
            from_glib(ffi::gdk_dmabuf_formats_contains(
                self.to_glib_none().0,
                fourcc,
                modifier,
            ))
        }
    }

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

    #[doc(alias = "gdk_dmabuf_formats_get_format")]
    #[doc(alias = "get_format")]
    pub fn format(&self, idx: usize) -> (u32, u64) {
        unsafe {
            let mut fourcc = std::mem::MaybeUninit::uninit();
            let mut modifier = std::mem::MaybeUninit::uninit();
            ffi::gdk_dmabuf_formats_get_format(
                self.to_glib_none().0,
                idx,
                fourcc.as_mut_ptr(),
                modifier.as_mut_ptr(),
            );
            (fourcc.assume_init(), modifier.assume_init())
        }
    }

    #[doc(alias = "gdk_dmabuf_formats_get_n_formats")]
    #[doc(alias = "get_n_formats")]
    pub fn n_formats(&self) -> usize {
        unsafe { ffi::gdk_dmabuf_formats_get_n_formats(self.to_glib_none().0) }
    }
}

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

impl Eq for DmabufFormats {}