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