cogl/
kms_crtc.rs

1use glib::translate::*;
2use std::mem;
3
4#[repr(C)]
5#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
6pub struct KmsCrtc {
7    pub id: u32,
8    pub x: u32,
9    pub y: u32,
10    // _truncated_record_marker: libc::c_void, // TODO: deal with it
11}
12
13#[doc(hidden)]
14impl Uninitialized for KmsCrtc {
15    #[inline]
16    unsafe fn uninitialized() -> Self {
17        mem::zeroed()
18    }
19}
20
21#[doc(hidden)]
22impl<'a> ToGlibPtr<'a, *const ffi::CoglKmsCrtc> for KmsCrtc {
23    type Storage = &'a Self;
24
25    #[inline]
26    fn to_glib_none(&'a self) -> Stash<'a, *const ffi::CoglKmsCrtc, Self> {
27        let ptr: *const KmsCrtc = &*self;
28        Stash(ptr as *const ffi::CoglKmsCrtc, self)
29    }
30}
31
32#[doc(hidden)]
33impl<'a> ToGlibPtrMut<'a, *mut ffi::CoglKmsCrtc> for KmsCrtc {
34    type Storage = &'a mut Self;
35
36    #[inline]
37    fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut ffi::CoglKmsCrtc, Self> {
38        let ptr: *mut KmsCrtc = &mut *self;
39        StashMut(ptr as *mut ffi::CoglKmsCrtc, self)
40    }
41}
42
43#[doc(hidden)]
44impl FromGlibPtrNone<*const ffi::CoglKmsCrtc> for KmsCrtc {
45    unsafe fn from_glib_none(ptr: *const ffi::CoglKmsCrtc) -> Self {
46        *(ptr as *const KmsCrtc)
47    }
48}
49
50#[doc(hidden)]
51impl FromGlibPtrNone<*mut ffi::CoglKmsCrtc> for KmsCrtc {
52    unsafe fn from_glib_none(ptr: *mut ffi::CoglKmsCrtc) -> Self {
53        *(ptr as *mut KmsCrtc)
54    }
55}
56
57#[doc(hidden)]
58impl FromGlibPtrBorrow<*mut ffi::CoglKmsCrtc> for KmsCrtc {
59    unsafe fn from_glib_borrow(ptr: *mut ffi::CoglKmsCrtc) -> glib::translate::Borrowed<Self> {
60        glib::translate::Borrowed::new(*(ptr as *mut KmsCrtc))
61    }
62}
63
64#[doc(hidden)]
65impl FromGlibPtrBorrow<*const ffi::CoglKmsCrtc> for KmsCrtc {
66    unsafe fn from_glib_borrow(ptr: *const ffi::CoglKmsCrtc) -> glib::translate::Borrowed<Self> {
67        glib::translate::Borrowed::new(*(ptr as *const KmsCrtc))
68    }
69}