// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

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())
    }
}
