1 | // Take a look at the license at the top of the repository in the LICENSE file. |
2 | |
3 | use crate::gobject_ffi; |
4 | |
5 | #[derive (Debug, Copy, Clone)] |
6 | #[doc (alias = "GTypeInfo" )] |
7 | #[repr (transparent)] |
8 | pub struct TypeInfo(pub(crate) gobject_ffi::GTypeInfo); |
9 | |
10 | impl TypeInfo { |
11 | // rustdoc-stripper-ignore-next |
12 | /// Returns a `GTypeInfo` pointer. |
13 | #[doc (hidden)] |
14 | #[inline ] |
15 | pub fn as_ptr(&self) -> *mut gobject_ffi::GTypeInfo { |
16 | &self.0 as *const gobject_ffi::GTypeInfo as *mut _ |
17 | } |
18 | |
19 | // rustdoc-stripper-ignore-next |
20 | /// Borrows the underlying C value mutably. |
21 | #[doc (hidden)] |
22 | #[inline ] |
23 | pub unsafe fn from_glib_ptr_borrow_mut<'a>(ptr: *mut gobject_ffi::GTypeInfo) -> &'a mut Self { |
24 | &mut *(ptr as *mut Self) |
25 | } |
26 | } |
27 | |
28 | impl Default for TypeInfo { |
29 | // rustdoc-stripper-ignore-next |
30 | /// Creates a new TypeInfo with default value. |
31 | fn default() -> Self { |
32 | Self(gobject_ffi::GTypeInfo { |
33 | class_size: 0u16, |
34 | base_init: None, |
35 | base_finalize: None, |
36 | class_init: None, |
37 | class_finalize: None, |
38 | class_data: ::std::ptr::null(), |
39 | instance_size: 0, |
40 | n_preallocs: 0, |
41 | instance_init: None, |
42 | value_table: ::std::ptr::null(), |
43 | }) |
44 | } |
45 | } |
46 | |