pango/
attr_class.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::marker::PhantomData;
4
5use glib::translate::*;
6
7use crate::{ffi, AttrType};
8
9#[doc(hidden)]
10impl<'a> ToGlibPtr<'a, *mut ffi::PangoAttrClass> for &'a AttrClass {
11    type Storage = PhantomData<&'a AttrClass>;
12
13    #[inline]
14    fn to_glib_none(&self) -> Stash<'a, *mut ffi::PangoAttrClass, Self> {
15        Stash(self.0, PhantomData)
16    }
17}
18
19#[doc(hidden)]
20impl FromGlibPtrNone<*mut ffi::PangoAttrClass> for AttrClass {
21    #[inline]
22    unsafe fn from_glib_none(ptr: *mut ffi::PangoAttrClass) -> Self {
23        debug_assert!(!ptr.is_null());
24        Self(ptr)
25    }
26}
27
28#[doc(hidden)]
29impl FromGlibPtrFull<*mut ffi::PangoAttrClass> for AttrClass {
30    #[inline]
31    unsafe fn from_glib_full(ptr: *mut ffi::PangoAttrClass) -> Self {
32        debug_assert!(!ptr.is_null());
33        Self(ptr)
34    }
35}
36
37#[doc(hidden)]
38impl FromGlibPtrNone<*const ffi::PangoAttrClass> for AttrClass {
39    #[inline]
40    unsafe fn from_glib_none(ptr: *const ffi::PangoAttrClass) -> Self {
41        debug_assert!(!ptr.is_null());
42        Self(ptr as *mut _)
43    }
44}
45
46#[doc(hidden)]
47impl FromGlibPtrFull<*const ffi::PangoAttrClass> for AttrClass {
48    #[inline]
49    unsafe fn from_glib_full(ptr: *const ffi::PangoAttrClass) -> Self {
50        debug_assert!(!ptr.is_null());
51        Self(ptr as *mut _)
52    }
53}
54
55/// The [`AttrClass`][crate::AttrClass] structure stores the type and operations for
56/// a particular type of attribute.
57///
58/// The functions in this structure should not be called directly. Instead,
59/// one should use the wrapper functions provided for [`Attribute`][crate::Attribute].
60#[doc(alias = "PangoAttrClass")]
61pub struct AttrClass(*mut ffi::PangoAttrClass);
62
63impl AttrClass {
64    #[inline]
65    pub fn type_(&self) -> AttrType {
66        unsafe { from_glib((*self.0).type_) }
67    }
68}
69
70impl PartialEq for AttrClass {
71    #[inline]
72    fn eq(&self, other: &AttrClass) -> bool {
73        self.0 == other.0
74    }
75}
76
77impl Eq for AttrClass {}