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 31 32 33 34 35 36 37 38
// 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 {
/// Gets the file attribute with the name `name` from `self`.
/// ## `name`
/// the name of the attribute to look up.
///
/// # Returns
///
/// a [`FileAttributeInfo`][crate::FileAttributeInfo] for the `name`, or [`None`] if an
/// attribute isn't found.
#[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)
}
}
}