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