[][src]Function xdg_utils::query_mime_info

pub fn query_mime_info<T: AsRef<Path>>(query: T) -> Result<Vec<u8>>

Returns the MIME type of given file https://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-mime.in

Example

use xdg_utils::query_mime_info;
let result = query_mime_info("/bin/sh")
                .map_err(|_| ())
                .map(|bytes| String::from_utf8_lossy(&bytes).into_owned());
let result_str = result.as_ref().map(|s| s.as_str());
assert!(Ok("application/x-pie-executable") == result_str || Ok("application/x-sharedlib") == result_str)