gio/auto/
file_attribute_info_list.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, FileAttributeInfoFlags, FileAttributeType};
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Acts as a lightweight registry for possible valid file attributes.
10    /// The registry stores Key-Value pair formats as #GFileAttributeInfos.
11    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
12    pub struct FileAttributeInfoList(Shared<ffi::GFileAttributeInfoList>);
13
14    match fn {
15        ref => |ptr| ffi::g_file_attribute_info_list_ref(ptr),
16        unref => |ptr| ffi::g_file_attribute_info_list_unref(ptr),
17        type_ => || ffi::g_file_attribute_info_list_get_type(),
18    }
19}
20
21impl FileAttributeInfoList {
22    /// Creates a new file attribute info list.
23    ///
24    /// # Returns
25    ///
26    /// a #GFileAttributeInfoList.
27    #[doc(alias = "g_file_attribute_info_list_new")]
28    pub fn new() -> FileAttributeInfoList {
29        unsafe { from_glib_full(ffi::g_file_attribute_info_list_new()) }
30    }
31
32    /// Adds a new attribute with @name to the @self, setting
33    /// its @type_ and @flags.
34    /// ## `name`
35    /// the name of the attribute to add.
36    /// ## `type_`
37    /// the #GFileAttributeType for the attribute.
38    /// ## `flags`
39    /// #GFileAttributeInfoFlags for the attribute.
40    #[doc(alias = "g_file_attribute_info_list_add")]
41    pub fn add(&self, name: &str, type_: FileAttributeType, flags: FileAttributeInfoFlags) {
42        unsafe {
43            ffi::g_file_attribute_info_list_add(
44                self.to_glib_none().0,
45                name.to_glib_none().0,
46                type_.into_glib(),
47                flags.into_glib(),
48            );
49        }
50    }
51
52    /// Makes a duplicate of a file attribute info list.
53    ///
54    /// # Returns
55    ///
56    /// a copy of the given @self.
57    #[doc(alias = "g_file_attribute_info_list_dup")]
58    #[must_use]
59    pub fn dup(&self) -> FileAttributeInfoList {
60        unsafe { from_glib_full(ffi::g_file_attribute_info_list_dup(self.to_glib_none().0)) }
61    }
62}
63
64impl Default for FileAttributeInfoList {
65    fn default() -> Self {
66        Self::new()
67    }
68}