cairo/
rectangle_int.rs

1use ffi;
2#[cfg(feature = "use_glib")]
3use glib::translate::*;
4use std::fmt;
5#[cfg(feature = "use_glib")]
6use std::mem;
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
9#[repr(C)]
10pub 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)]
19impl Uninitialized for RectangleInt {
20    #[inline]
21    unsafe fn uninitialized() -> Self {
22        mem::uninitialized()
23    }
24}
25
26#[cfg(feature = "use_glib")]
27#[doc(hidden)]
28impl<'a> ToGlibPtr<'a, *const ffi::cairo_rectangle_int_t> for RectangleInt {
29    type Storage = &'a Self;
30
31    #[inline]
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)]
40impl<'a> ToGlibPtrMut<'a, *mut ffi::cairo_rectangle_int_t> for RectangleInt {
41    type Storage = &'a mut Self;
42
43    #[inline]
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)]
52impl FromGlibPtrNone<*const ffi::cairo_rectangle_int_t> for RectangleInt {
53    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)]
60impl FromGlibPtrBorrow<*mut ffi::cairo_rectangle_int_t> for RectangleInt {
61    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)]
68impl FromGlibPtrNone<*mut ffi::cairo_rectangle_int_t> for RectangleInt {
69    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")]
75gvalue_impl!(
76    RectangleInt,
77    ffi::cairo_rectangle_int_t,
78    ffi::gobject::cairo_gobject_rectangle_int_get_type
79);
80
81impl RectangleInt {
82    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
88impl fmt::Display for RectangleInt {
89    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
90        write!(f, "RectangleInt")
91    }
92}