alpm_mtree::mtree::v2

Function path_from_parsed

Source
fn path_from_parsed(
    content: &str,
    line_nr: usize,
    defaults: &PathDefaults,
    path: PathBuf,
    properties: Vec<PathProperty<'_>>,
) -> Result<Path, Error>
Expand description

Create the actual final MTREE path representation from the parsed input.

This is the core of the mtree interpreter logic and does a few critical things:

  • Incorporate default properties specified by previous /set and /unset statements.
  • Ensure all paths have all necessary properties for the given path type.

The way this works is as follows: Go through all given properties and collect them in local Option<T> variables. Afterwards, look at the path_type and ensure that all necessary properties for the given path type are set. If all properties are there, initialize the respective Path type and return it.

The original content (content), as well as line number (line_nr) are passed in as well to provide detailed error messages.

§Errors

  • Error::InterpreterError if expected properties for a given type aren’t set.