use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FileAttributeMatcher(Shared<ffi::GFileAttributeMatcher>);
match fn {
ref => |ptr| ffi::g_file_attribute_matcher_ref(ptr),
unref => |ptr| ffi::g_file_attribute_matcher_unref(ptr),
type_ => || ffi::g_file_attribute_matcher_get_type(),
}
}
impl FileAttributeMatcher {
#[doc(alias = "g_file_attribute_matcher_new")]
pub fn new(attributes: &str) -> FileAttributeMatcher {
unsafe {
from_glib_full(ffi::g_file_attribute_matcher_new(
attributes.to_glib_none().0,
))
}
}
#[doc(alias = "g_file_attribute_matcher_enumerate_namespace")]
pub fn enumerate_namespace(&self, ns: &str) -> bool {
unsafe {
from_glib(ffi::g_file_attribute_matcher_enumerate_namespace(
self.to_glib_none().0,
ns.to_glib_none().0,
))
}
}
#[doc(alias = "g_file_attribute_matcher_matches")]
pub fn matches(&self, attribute: &str) -> bool {
unsafe {
from_glib(ffi::g_file_attribute_matcher_matches(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
#[doc(alias = "g_file_attribute_matcher_matches_only")]
pub fn matches_only(&self, attribute: &str) -> bool {
unsafe {
from_glib(ffi::g_file_attribute_matcher_matches_only(
self.to_glib_none().0,
attribute.to_glib_none().0,
))
}
}
#[doc(alias = "g_file_attribute_matcher_subtract")]
#[must_use]
pub fn subtract(
&self,
subtract: Option<&FileAttributeMatcher>,
) -> Option<FileAttributeMatcher> {
unsafe {
from_glib_full(ffi::g_file_attribute_matcher_subtract(
self.to_glib_none().0,
subtract.to_glib_none().0,
))
}
}
#[doc(alias = "g_file_attribute_matcher_to_string")]
#[doc(alias = "to_string")]
pub fn to_str(&self) -> glib::GString {
unsafe {
from_glib_full(ffi::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 {
f.write_str(&self.to_str())
}
}