gio/auto/
file_attribute_matcher.rs1use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
10 pub struct FileAttributeMatcher(Shared<ffi::GFileAttributeMatcher>);
11
12 match fn {
13 ref => |ptr| ffi::g_file_attribute_matcher_ref(ptr),
14 unref => |ptr| ffi::g_file_attribute_matcher_unref(ptr),
15 type_ => || ffi::g_file_attribute_matcher_get_type(),
16 }
17}
18
19impl FileAttributeMatcher {
20 #[doc(alias = "g_file_attribute_matcher_new")]
21 pub fn new(attributes: &str) -> FileAttributeMatcher {
22 unsafe {
23 from_glib_full(ffi::g_file_attribute_matcher_new(
24 attributes.to_glib_none().0,
25 ))
26 }
27 }
28
29 #[doc(alias = "g_file_attribute_matcher_enumerate_namespace")]
30 pub fn enumerate_namespace(&self, ns: &str) -> bool {
31 unsafe {
32 from_glib(ffi::g_file_attribute_matcher_enumerate_namespace(
33 self.to_glib_none().0,
34 ns.to_glib_none().0,
35 ))
36 }
37 }
38
39 #[doc(alias = "g_file_attribute_matcher_matches")]
40 pub fn matches(&self, attribute: &str) -> bool {
41 unsafe {
42 from_glib(ffi::g_file_attribute_matcher_matches(
43 self.to_glib_none().0,
44 attribute.to_glib_none().0,
45 ))
46 }
47 }
48
49 #[doc(alias = "g_file_attribute_matcher_matches_only")]
50 pub fn matches_only(&self, attribute: &str) -> bool {
51 unsafe {
52 from_glib(ffi::g_file_attribute_matcher_matches_only(
53 self.to_glib_none().0,
54 attribute.to_glib_none().0,
55 ))
56 }
57 }
58
59 #[doc(alias = "g_file_attribute_matcher_subtract")]
60 #[must_use]
61 pub fn subtract(
62 &self,
63 subtract: Option<&FileAttributeMatcher>,
64 ) -> Option<FileAttributeMatcher> {
65 unsafe {
66 from_glib_full(ffi::g_file_attribute_matcher_subtract(
67 self.to_glib_none().0,
68 subtract.to_glib_none().0,
69 ))
70 }
71 }
72
73 #[doc(alias = "g_file_attribute_matcher_to_string")]
74 #[doc(alias = "to_string")]
75 pub fn to_str(&self) -> glib::GString {
76 unsafe {
77 from_glib_full(ffi::g_file_attribute_matcher_to_string(
78 self.to_glib_none().0,
79 ))
80 }
81 }
82}
83
84impl std::fmt::Display for FileAttributeMatcher {
85 #[inline]
86 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
87 f.write_str(&self.to_str())
88 }
89}