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
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::FileAttributeInfo;
use crate::FileAttributeInfoList;

use glib::translate::*;

impl FileAttributeInfoList {
    #[doc(alias = "g_file_attribute_info_list_lookup")]
    pub fn lookup(&self, name: &str) -> Option<FileAttributeInfo> {
        unsafe {
            let res = ffi::g_file_attribute_info_list_lookup(
                self.to_glib_none().0,
                name.to_glib_none().0,
            );
            if res.is_null() {
                None
            } else {
                Some(from_glib_none(res))
            }
        }
    }

    pub fn attributes(&self) -> Vec<FileAttributeInfo> {
        unsafe {
            let ptr: *const _ = self.to_glib_none().0;
            FromGlibContainer::from_glib_none_num((*ptr).infos, (*ptr).n_infos as usize)
        }
    }
}