Function parse

Source
pub fn parse(input: &str) -> Result<DesktopFile, ParseError>
Expand description

Parses a desktop file’s content into a structured DesktopFile.

§Arguments

  • input - The string content of a .desktop file

§Returns

  • Ok(DesktopFile) - Successfully parsed desktop file with all entries and actions
  • Err(ParseError) - If the file cannot be parsed or is missing required fields

§Examples

let content = r#"[Desktop Entry]
Type=Application
Name=Firefox
Exec=firefox %u"#;

let desktop_file = freedesktop_file_parser::parse(content).unwrap();
assert_eq!(desktop_file.entry.name.default, "Firefox");