Skip to main content

parse_section

Function parse_section 

Source
pub fn parse_section(text: &str, section: &str) -> BTreeMap<String, Vec<String>>
Expand description

Any one section of a mimeapps.list — or of mimeinfo.cache, which has the same shape and is read by this too (see crate::apps::parse_cache).

The three that matter here are the defaults, the associations a person added, and the ones they removed — see ADDED_SECTION and REMOVED_SECTION. A removal is not a smaller kind of default: it says “never offer this for that type”, and a chooser that ignores it keeps putting back something somebody deliberately took away.

A key that appears twice in one section keeps the entries of both, first occurrence first — the same “the earlier rule wins” the glob matcher settled on, so that a caller taking .first() gets the answer it would get from two files in directory order.