pango/
attr_list.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::mem;
4
5use glib::translate::*;
6
7use crate::{ffi, AttrIterator, AttrList, Attribute};
8
9impl AttrList {
10    #[doc(alias = "pango_attr_list_change")]
11    pub fn change(&self, attr: impl Into<Attribute>) {
12        unsafe {
13            let attr = attr.into();
14            ffi::pango_attr_list_change(self.to_glib_none().0, attr.to_glib_none().0);
15            mem::forget(attr); //As attr transferred fully
16        }
17    }
18
19    #[cfg(feature = "v1_46")]
20    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
21    #[doc(alias = "pango_attr_list_equal")]
22    fn equal(&self, other_list: &AttrList) -> bool {
23        unsafe {
24            from_glib(ffi::pango_attr_list_equal(
25                self.to_glib_none().0,
26                other_list.to_glib_none().0,
27            ))
28        }
29    }
30
31    #[doc(alias = "pango_attr_list_insert")]
32    pub fn insert(&self, attr: impl Into<Attribute>) {
33        unsafe {
34            let attr = attr.into();
35            ffi::pango_attr_list_insert(self.to_glib_none().0, attr.to_glib_none().0);
36            mem::forget(attr); //As attr transferred fully
37        }
38    }
39
40    #[doc(alias = "pango_attr_list_insert_before")]
41    pub fn insert_before(&self, attr: impl Into<Attribute>) {
42        unsafe {
43            let attr = attr.into();
44            ffi::pango_attr_list_insert_before(self.to_glib_none().0, attr.to_glib_none().0);
45            mem::forget(attr); //As attr transferred fully
46        }
47    }
48
49    #[doc(alias = "pango_attr_list_get_iterator")]
50    #[doc(alias = "get_iterator")]
51    pub fn iterator(&self) -> AttrIterator<'_> {
52        unsafe { from_glib_full(ffi::pango_attr_list_get_iterator(self.to_glib_none().0)) }
53    }
54}
55
56#[cfg(feature = "v1_46")]
57#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
58impl PartialEq for AttrList {
59    #[inline]
60    fn eq(&self, other: &Self) -> bool {
61        self.equal(other)
62    }
63}
64
65#[cfg(feature = "v1_46")]
66#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
67impl Eq for AttrList {}
68
69#[cfg(feature = "v1_50")]
70#[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
71impl std::str::FromStr for AttrList {
72    type Err = glib::BoolError;
73
74    fn from_str(s: &str) -> Result<Self, Self::Err> {
75        Self::from_string(s)
76    }
77}