Skip to main content

parse_indented

Function parse_indented 

Source
pub fn parse_indented(
    text: &str,
) -> Result<(String, HashMap<String, String>), FormatError>
Expand description

Parse an indented Links Notation string back to an object.

This function uses the links-notation parser for proper parsing, supporting the standard Links Notation indented syntax.

Parses strings like:

<identifier>
  <key> "<value>"
  <key> "<value>"
  ...

The format with colon after identifier is also supported (standard lino):

<identifier>:
  <key> "<value>"

§Arguments

  • text - The indented Links Notation string to parse

§Returns

A tuple of (id, HashMap of key-value pairs), or an error

§Example

use lino_objects_codec::format::parse_indented;

let text = "my-uuid\n  status \"executed\"\n  exitCode \"0\"";
let (id, obj) = parse_indented(text).unwrap();
assert_eq!(id, "my-uuid");
assert_eq!(obj.get("status"), Some(&"executed".to_string()));