1 use ffi; 2 #[cfg(feature = "use_glib")] 3 use glib::translate::*; 4 use std::fmt; 5 #[cfg(feature = "use_glib")] 6 use std::mem; 7 8 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 9 #[repr(C)] 10 pub struct RectangleInt { 11 pub x: i32, 12 pub y: i32, 13 pub width: i32, 14 pub height: i32, 15 } 16 17 #[cfg(feature = "use_glib")] 18 #[doc(hidden)] 19 impl Uninitialized for RectangleInt { 20 #[inline] uninitialized() -> Self21 unsafe fn uninitialized() -> Self { 22 mem::uninitialized() 23 } 24 } 25 26 #[cfg(feature = "use_glib")] 27 #[doc(hidden)] 28 impl<'a> ToGlibPtr<'a, *const ffi::cairo_rectangle_int_t> for RectangleInt { 29 type Storage = &'a Self; 30 31 #[inline] to_glib_none(&'a self) -> Stash<'a, *const ffi::cairo_rectangle_int_t, Self>32 fn to_glib_none(&'a self) -> Stash<'a, *const ffi::cairo_rectangle_int_t, Self> { 33 let ptr: *const RectangleInt = &*self; 34 Stash(ptr as *const ffi::cairo_rectangle_int_t, self) 35 } 36 } 37 38 #[cfg(feature = "use_glib")] 39 #[doc(hidden)] 40 impl<'a> ToGlibPtrMut<'a, *mut ffi::cairo_rectangle_int_t> for RectangleInt { 41 type Storage = &'a mut Self; 42 43 #[inline] to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut ffi::cairo_rectangle_int_t, Self>44 fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut ffi::cairo_rectangle_int_t, Self> { 45 let ptr: *mut RectangleInt = &mut *self; 46 StashMut(ptr as *mut ffi::cairo_rectangle_int_t, self) 47 } 48 } 49 50 #[cfg(feature = "use_glib")] 51 #[doc(hidden)] 52 impl FromGlibPtrNone<*const ffi::cairo_rectangle_int_t> for RectangleInt { from_glib_none(ptr: *const ffi::cairo_rectangle_int_t) -> Self53 unsafe fn from_glib_none(ptr: *const ffi::cairo_rectangle_int_t) -> Self { 54 *(ptr as *const RectangleInt) 55 } 56 } 57 58 #[cfg(feature = "use_glib")] 59 #[doc(hidden)] 60 impl FromGlibPtrBorrow<*mut ffi::cairo_rectangle_int_t> for RectangleInt { from_glib_borrow(ptr: *mut ffi::cairo_rectangle_int_t) -> Self61 unsafe fn from_glib_borrow(ptr: *mut ffi::cairo_rectangle_int_t) -> Self { 62 *(ptr as *mut RectangleInt) 63 } 64 } 65 66 #[cfg(feature = "use_glib")] 67 #[doc(hidden)] 68 impl FromGlibPtrNone<*mut ffi::cairo_rectangle_int_t> for RectangleInt { from_glib_none(ptr: *mut ffi::cairo_rectangle_int_t) -> Self69 unsafe fn from_glib_none(ptr: *mut ffi::cairo_rectangle_int_t) -> Self { 70 *(ptr as *mut RectangleInt) 71 } 72 } 73 74 #[cfg(feature = "use_glib")] 75 gvalue_impl!( 76 RectangleInt, 77 ffi::cairo_rectangle_int_t, 78 ffi::gobject::cairo_gobject_rectangle_int_get_type 79 ); 80 81 impl RectangleInt { to_raw_none(&self) -> *mut ffi::cairo_rectangle_int_t82 pub fn to_raw_none(&self) -> *mut ffi::cairo_rectangle_int_t { 83 let ptr = &*self as *const RectangleInt as usize; 84 ptr as *mut ffi::cairo_rectangle_int_t 85 } 86 } 87 88 impl fmt::Display for RectangleInt { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result89 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 90 write!(f, "RectangleInt") 91 } 92 } 93