Skip to main content

format_indented

Function format_indented 

Source
pub fn format_indented<S: BuildHasher>(
    id: &str,
    obj: &HashMap<String, String, S>,
    indent: &str,
) -> Result<String, FormatError>
Expand description

Format an object in indented Links Notation format.

This format is designed for human readability, displaying objects as:

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

§Arguments

  • id - The object identifier (displayed on first line)
  • obj - The object as key-value pairs to format
  • indent - The indentation string (default: 2 spaces)

§Returns

Formatted indented Links Notation string, or an error

§Example

use lino_objects_codec::format::format_indented;
use std::collections::HashMap;

let mut obj = HashMap::new();
obj.insert("status".to_string(), "executed".to_string());
obj.insert("exitCode".to_string(), "0".to_string());

let result = format_indented("my-uuid", &obj, "  ").unwrap();
assert!(result.starts_with("my-uuid\n"));