[go: up one dir, main page]

gdk4/auto/
dmabuf_formats.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9    #[derive(Debug, PartialOrd, Ord, Hash)]
10    pub struct DmabufFormats(Shared<ffi::GdkDmabufFormats>);
11
12    match fn {
13        ref => |ptr| ffi::gdk_dmabuf_formats_ref(ptr),
14        unref => |ptr| ffi::gdk_dmabuf_formats_unref(ptr),
15        type_ => || ffi::gdk_dmabuf_formats_get_type(),
16    }
17}
18
19impl DmabufFormats {
20    #[doc(alias = "gdk_dmabuf_formats_contains")]
21    pub fn contains(&self, fourcc: u32, modifier: u64) -> bool {
22        unsafe {
23            from_glib(ffi::gdk_dmabuf_formats_contains(
24                self.to_glib_none().0,
25                fourcc,
26                modifier,
27            ))
28        }
29    }
30
31    #[doc(alias = "gdk_dmabuf_formats_equal")]
32    fn equal(&self, formats2: &DmabufFormats) -> bool {
33        unsafe {
34            from_glib(ffi::gdk_dmabuf_formats_equal(
35                self.to_glib_none().0,
36                formats2.to_glib_none().0,
37            ))
38        }
39    }
40
41    #[doc(alias = "gdk_dmabuf_formats_get_format")]
42    #[doc(alias = "get_format")]
43    pub fn format(&self, idx: usize) -> (u32, u64) {
44        unsafe {
45            let mut fourcc = std::mem::MaybeUninit::uninit();
46            let mut modifier = std::mem::MaybeUninit::uninit();
47            ffi::gdk_dmabuf_formats_get_format(
48                self.to_glib_none().0,
49                idx,
50                fourcc.as_mut_ptr(),
51                modifier.as_mut_ptr(),
52            );
53            (fourcc.assume_init(), modifier.assume_init())
54        }
55    }
56
57    #[doc(alias = "gdk_dmabuf_formats_get_n_formats")]
58    #[doc(alias = "get_n_formats")]
59    pub fn n_formats(&self) -> usize {
60        unsafe { ffi::gdk_dmabuf_formats_get_n_formats(self.to_glib_none().0) }
61    }
62}
63
64impl PartialEq for DmabufFormats {
65    #[inline]
66    fn eq(&self, other: &Self) -> bool {
67        self.equal(other)
68    }
69}
70
71impl Eq for DmabufFormats {}