gio/file_attribute_info_list.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, FileAttributeInfo, FileAttributeInfoList};
6
7impl FileAttributeInfoList {
8 /// Gets the file attribute with the name @name from @self.
9 /// ## `name`
10 /// the name of the attribute to look up.
11 ///
12 /// # Returns
13 ///
14 /// a #GFileAttributeInfo for the @name, or [`None`] if an
15 /// attribute isn't found.
16 #[doc(alias = "g_file_attribute_info_list_lookup")]
17 pub fn lookup(&self, name: &str) -> Option<FileAttributeInfo> {
18 unsafe {
19 let res = ffi::g_file_attribute_info_list_lookup(
20 self.to_glib_none().0,
21 name.to_glib_none().0,
22 );
23 if res.is_null() {
24 None
25 } else {
26 Some(from_glib_none(res))
27 }
28 }
29 }
30
31 pub fn attributes(&self) -> Vec<FileAttributeInfo> {
32 unsafe {
33 let ptr: *const _ = self.to_glib_none().0;
34 FromGlibContainer::from_glib_none_num((*ptr).infos, (*ptr).n_infos as usize)
35 }
36 }
37}